Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

408
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda