本文介绍了SQL F#类型提供程序,App.Config和ConnectionStrings?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用app.config文件将连接字符串加载到类型提供程序中,但是收到以下错误:
I am trying to use app.config file to load the connection string into the type provider but I am receiving the following error:
我将连接字符串这样放置在app.config文件中:
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>
,然后在F#中按如下方式引用它们:
and then reference them in F# as so:
type dbSchema = SqlDataConnection<ConnectionStringName = "Server1", Views = false, Functions = false, StoredProcedures = false>
有什么想法吗?
推荐答案
请为连接字符串提供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
失败,并显示了您报告的消息.
I've adjusted the provided app.config
, Server1
functions, Server2
fails with the message you've reported.
这篇关于SQL F#类型提供程序,App.Config和ConnectionStrings?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!