Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

409
Views
How to connect to MS SQL Server with F# with SQLProvider?

I'm trying to use the SQLProvider for MS SQL Server with F#, but it appears that it's not possible with the recommended setup.

See my module below:

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>

My main problem is that after adding in this code I get this message/warning in intellisense

The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: System.Data.SqlClient is not supported on this platform.F# Compiler(3033)

and a build error when attempting to compile:

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

Is there something that I'm doing wrong, or is this really just not possible to use the default setup along with latest .NET and F# and I need to submit a git issue? Any insights and critiques welcomed, thanks!

In use at the time of posting:

  • .NET 6
  • VS Code (1.62.2)
  • Ionide (v5.9.0)
  • SQLProvider Version 1.2.10
  • System.Data.SqlClient Version 4.8.3
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To resolve this issue, I opened the project within Visual Studio (v17 2022) and did the following:

  • removed dependencies
  • added back in SQLProvider and System.Data.SqlClient (v4.8.3)
  • cleared out bin and obj folders

After doing the above I was able to run the application and get a connection to the database followed by a simple select query that returned expected data.

Not sure why, but Ionide always gives the dreaded red squigglies even when things build just fine.

over 4 years ago · Santiago Trujillo Report

0

Run from command line: dotnet add package microsoft.data.sqlclient

then change Common.DatabaseProviderTypes.MSSQLSERVER to Common.DatabaseProviderTypes.MSSQLSERVER_DYNAMIC

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!