/FSharp.Data.SqlClient-dotnet

How to use fsc.props to make FSharp.Data.SqlClient work on .NET Core

Primary LanguageF#MIT LicenseMIT

FSharp.Data.SqlClient-dotnet

How to use fsc.props to make FSharp.Data.SqlClient work on .NET Core

As of 2020-03-20, FSharp.Data.SqlClient does not work out of the box with .NET Core. We still need to use the fsc.props workaround described here:

[Obsolete] How to enable type providers with new-style .NET SDK project files, dotnet build, .NET Standard and .NET Core programming

The workaround has been obsoleted, but for some Type Providers this may still be a problem.

Also described here:

Could not load file or assembly System.Data.SqlClient if building using dotnet build

This project includes an fsc.props file. I have included FscToolPath references to the fsc.exe for Visual Studio 2019 so you do not have to have Visual Studio 2017 installed.

See also here for reference:

added Visual Studio Build tools FscToolPath Can't dotnet build apps with TypeProviders if installed the F# compiler with Visual Studio Build Tools

Dependencies

You will need to have Visual Studio 2017 or Visual Studio 2019 installed. If you don't want to install Visual Studio or if you are running on a Build Server, you can install the Visual Studio Build Tools

Download here

Steps to build

  1. Clone the repo
  2. dotnet build

If you see this error:

 error FS3033: The type provider 'FSharp.Data.SqlCommandProvider' reported an error: 
 A network-related or instance-specific error occurred while establishing a connection to SQL Server. 
 The server was not found or was not accessible. Verify that the instance name is correct and 
 that SQL Server is configured to allow remote connections.

You are in good shape. To further test, go into src/lib/Example.fs and change the connection string to point to your database and change the query to make sense for you schema.

Putting the fsc.props file at the solution level

I like to keep fsc.props at the solution level so I can import it into any projects I have in my solution.