我正在尝试使用app.config文件将连接字符串加载到类型提供程序中,但是我收到以下错误:
错误FS3033:类型提供程序
'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
报告错误:配置文件''
中连接字符串条目'Server1'
中的提供程序'...\app.config'
无效。SqlDataConnection
只能与提供商'System.Data.SqlClient'
一起使用。
我将连接字符串放在app.config文件中,如下所示:
<?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>
然后在F#中引用它们:
type dbSchema = SqlDataConnection<ConnectionStringName = "Server1", Views = false, Functions = false, StoredProcedures = false>
问题出在哪里?
答案 0 :(得分:0)
请提供providerName
连接字符串。
<?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>
我已调整提供的app.config
,Server1
功能,Server2
因您报告的消息而失败。