我试图使用SQLProvider连接F#和MS SQL Server,但似乎无法在建议的环境下实现。
请查看我的模块如下:
namespace MyApp
open FSharp.Data.Sql
module Database =
[<Literal>]
let dbVendor = Common.DatabaseProviderTypes.MSSQLSERVER
[<Literal>]
let connString =
"Data Source=localhost;Database=MyDatabase;User Id=user;Password='my-password-here'"
[<Literal>]
let indivAmount = 1000
[<Literal>]
let useOptTypes = true
type sql = SqlDataProvider<dbVendor, connString, IndividualsAmount=indivAmount, UseOptionTypes=useOptTypes>
我的主要问题在于加入这段代码后,我在Intellisense中看到了以下信息/警告:
类型提供程序“FSharp.Data.Sql.SqlTypeProvider”报告了一个错误:System.Data.SqlClient在此平台上不受支持。F#编译器(3033)
并且在尝试编译时出现了构建错误:
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
C:\Development\F#\MyApp\DataTypes.fs(21,16): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform. [C:\Development\F#\MyApp\MyApp.fsproj]
C:\Development\F#\MyApp\DataTypes.fs(21,16): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform. [C:\Development\F#\MyApp\MyApp.fsproj]
Build FAILED.
C:\Development\F#\MyApp\DataTypes.fs(21,16): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform. [C:\Development\F#\MyApp\MyApp.fsproj]
C:\Development\F#\MyApp\DataTypes.fs(21,16): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform. [C:\Development\F#\MyApp\MyApp.fsproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:06.21
我是否做错了什么,或者说默认设置无法与最新的.NET和F#一起使用,我需要提交一个git问题吗?欢迎任何见解和批评,谢谢!
发布时所使用的软件:
- .NET 6
- VS Code (1.62.2)
- Ionide (v5.9.0)
- SQLProvider 版本1.2.10
- System.Data.SqlClient 版本4.8.3
dotnet add package Microsoft.Data.SqlClient
呢? - masoodahm