0

I am trying to use app.config file to load the connection string into the type provider but I am receiving the following error:

error FS3033: The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Invalid provider '' in connection string entry 'Server1' in config file '...\app.config'. SqlDataConnection can only be used with provider 'System.Data.SqlClient'.

I put the connection strings in the app.config file as so:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="..." culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <connectionStrings>
    <add name="Server1" connectionString="Server=..."/>
    <add name="Server2" connectionString="Server=..."/>
  </connectionStrings>
</configuration>

and then reference them in F# as so:

type dbSchema = SqlDataConnection<ConnectionStringName = "Server1", Views = false, Functions = false, StoredProcedures = false>

Any thoughts where the issue is?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
user1129988
  • 1,516
  • 4
  • 19
  • 32
  • Can you post the full connection string from your app.config - you can anonymise the details - I suspect that might not be valid? – DaveShaw Feb 08 '15 at 14:57

1 Answers1

0

Please provide providerName for the connection string.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="..." culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <connectionStrings>
    <add name="Server1" connectionString="Server=..." providerName="System.Data.SqlClient"/>
    <add name="Server2" connectionString="Server=..."/>
  </connectionStrings>
</configuration>

I've adjusted the provided app.config, Server1 functions, Server2 fails with the message you've reported.

Max Malook
  • 513
  • 3
  • 9