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
578 stars 146 forks source link

Microsoft.Data.SqlClient with SSDT? #751

Open NickDarvey opened 2 years ago

NickDarvey commented 2 years ago

Description

I'm wanting to use Microsoft.Data.SqlClient with the SSDT Provider. The documentation say I need to use MSSQLSERVER_DYNAMIC, but is it possible with MSSQLSERVER_SSDT?

I've read the instructions in #645 and included the appropriate assemblies in a folder and set it as the resolutionPath. However, it fails trying to load System.Data.SqlClient.

Repro steps

[<Literal>]
let private Schema = __SOURCE_DIRECTORY__ + @"/../DatabaseProject/bin/Debug/DatabaseProject.dacpac"

type Schema = 
  SqlDataProvider<
    Common.DatabaseProviderTypes.MSSQLSERVER_SSDT, 
    SsdtPath = Schema,
    UseOptionTypes = true
  >

let create (connectionString: string) =
  Schema.GetDataContext(connectionString, resolutionPath = @"C:\testing\runtimes")

Expected behaviour

Please provide a description of the behaviour you expect.

Actual behaviour

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.6.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'

Known workarounds

None.

Related information

ratsclub commented 1 year ago

I'm currently facing the exact same issue. @NickDarvey did you find a solution for this?

JordanMarr commented 1 year ago

The MSSQLSERVER_SSDT provider is hardwired to use System.Data.SqlClient. I'm pretty sure the resolutionPath is designed to work in conjunction with the MSSQLSERVER_DYNAMIC provider only.

AFAIK, the only way to use Microsoft.Data.SqlClient with MSSQLSERVER_SSDT would be to change the provider (or create a new one).

NickDarvey commented 1 year ago

@NickDarvey did you find a solution for this?

I didn't, sorry @ratsclub

Thorium commented 1 year ago

@JordanMarr I would rather create a new one than change MSSQLSERVER_SSDT or has some kind of parameter to combine these... Microsoft.Data.SqlClient brings a huge dependency network https://github.com/fsprojects/SQLProvider/issues/724#issuecomment-1317362757, and if you look inside of it, mostly what it does is forwarding types to the old System.Data.SqlClient.

Thorium commented 1 year ago

The version 1.3.5 is now using Microsoft.Data.SqlClient on .Net6.0 and .NetStandard 2.1, and the old System.Data.SqlClient on .Net 4.7.2 and .NetStandard 2.0. This is initial trial via simple conditional compilation (because the base classes are the same) so please let me know if it works or not.