fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
579 stars 146 forks source link

Get error when trying to create SqlDataProvider<...> (Unless using VS 2019) #741

Closed arnesahlberg closed 3 years ago

arnesahlberg commented 3 years ago

Describe the bug When trying to create the SqlDataProvider I get the error "The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform." If I create the program with dotnet new and use Visual Studio Code, that is. However, if I do the same thing in Visual studio 2019 it works as it should. I'm wondering what could be wrong...

To Reproduce Steps to reproduce the behavior:

  1. Create new f# project with dotnet new using dotnet sdk 5 (get same error with 3)
  2. Add packages SQLProvider and System.Data.SqlClient using dotnet add package
  3. Try to create and SqlDataProvider type usign the code
    
    open FSharp.Data.Sql

let [] ConnStr = "Server=Localhost;Database=TestDB;User Id=SA;Password=mypassword";

type Sql = SqlDataProvider< Common.DatabaseProviderTypes.MSSQLSERVER, ConnStr>

let ctx = Sql.GetDataContext()


4. Get error _"The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform."_
5. Try the same thing with Visual Studio 2019, and import the same packages, and everything is working for some reason.

**Expected behavior**
That it should work in a console application created with the `dotnet new` command as well.

**Desktop (please complete the following information):**
 - OS: Windows with MSSQL Server running in Docker
Thorium commented 3 years ago

Are you loading System.Data.SqlClient dll from the platform, or from NuGet?

Thorium commented 3 years ago

I think VS2019 is running .NET Framework full as default, VS Code is running .NET Core as default. Both should work... But the version of needed database driver, System.Data.SqlClient, might be different. If you are not using the SSDT provider, then you can use MSSQLSERVER_DYNAMIC and load whatever driver you want.

arnesahlberg commented 3 years ago

Are you loading System.Data.SqlClient dll from the platform, or from NuGet?

I'm just adding the nuget package using dotnet add package. Do I need to do something more to add the dll?

Edit: Also, I tried to use MSSQLSERVER_DYNAMIC and it says it can't find the dll, so maybe there is a problem with that.

varon commented 3 years ago

Also saw a ton of this with Rider. Dacpac seems to work the best, but running into separate issues.

Thorium commented 3 years ago

The dynamic needs the resolutionpath setting for the library.