我创建了F#控制台应用程序(.NET 4.7.2),然后将Nuget包添加到FSharp.Data.SqlProvider
然后我用F#编写了这段代码
module File1
//#r "FSharp.Data.SqlProvider.dll"
open System
open FSharp.Data.Sql
let [<Literal>] dbVendor = Common.DatabaseProviderTypes.MSSQLSERVER
let [<Literal>] connString = "Server=localhost;Database=Northwind;Trusted_Connection=True"
let [<Literal>] useOptTypes = true
let [<Literal>] indivAmount = 1000
type sql =
SqlDataProvider<
dbVendor,
connString,
IndividualsAmount = indivAmount,
UseOptionTypes = useOptTypes>
let ctx = sql.GetDataContext()
构建完所有内容后,我会收到错误消息,这个错误是什么意思?
错误FS3021提供的类型意外的异常 'FSharp.Data.Sql.SqlDataProvider,DatabaseVendor =“ 0”,ConnectionString =“ Server = localhost; Database = Test; Trusted_Connection = True”,UseOptionTypes =“ True” + dataContext' 成员'GetMethods':类型提供者 'FSharp.Data.Sql.SqlTypeProvider'报告了一个错误:设计时 类型提供程序使用的类型“ System.Data.IDbConnection”不是 在目标参考程序集中找到'[tgt程序集 FSharp.Data.SqlProvider,版本= 1.1.62.0,文化=中性; tgt 程序集mscorlib,版本= 4.0.0.0,文化=中性, PublicKeyToken = b77a5c561934e089; tgt程序集FSharp.Core, 版本= 4.5.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a; tgt程序集System.Core,版本= 4.0.0.0,文化=中性, PublicKeyToken = b77a5c561934e089; tgt组装系统, 版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089; tgt assembly System.Numerics,版本= 4.0.0.0,文化=中性, PublicKeyToken = b77a5c561934e089; tgt程序集System.ValueTuple, 版本= 4.0.2.0,文化=中性,PublicKeyToken = cc7b13ffcd2ddd51]”。 您所引用的配置文件类型可能少于类型 您是类型提供者所需的 使用。 ConsoleApplicationF C:\ Users \ UserXXX \ source \ repos \ ConsoleApplicationF \ ConsoleApplicationF \ File1.fs 22有效
当我对NET CORE进行相同操作时,我会收到另一个错误
FS3033类型提供程序'FSharp.Data.Sql.SqlTypeProvider'报告了 提供的类型上下文中的错误 'FSharp.Data.Sql.SqlDataProvider,DatabaseVendor =“ 0”,ConnectionString =“ Server = localhost; Database = Test; Trusted_Connection = True”', 成员“ GetDataContext”。错误:方法'System.String tryGetConnectionString(Boolean,System.String,System.String, 在类型“”中找不到System.String)'。此方法可能会丢失 在目标部件中可用的类型中