SQL F#类型提供程序,App.Config和ConnectionStrings? [英] Sql F# Type Provider, App.Config, and 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:
错误FS3033:类型提供程序
'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders'
报告了一个错误:配置文件'...\app.config'
中的连接字符串条目'Server1'
中的无效提供程序''
.SqlDataConnection
只能与提供程序'System.Data.SqlClient'
一起使用.
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'
.
我将连接字符串这样放置在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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!