SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Microsoft.Data.SqlClient with SSDT?

Open NickDarvey opened this issue 2 years ago • 5 comments

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

  • Operating system
    • [x] windows [19043.1288]
    • [ ] macOs [insert version]
    • [ ] linux [insert flavor/version here]
  • Platform
    • [x] dotnet core [5.0.104]
    • [ ] dotnet full
    • [ ] mono
  • Branch or release version [1.2.10]

NickDarvey avatar Oct 22 '21 08:10 NickDarvey

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

ratsclub avatar Dec 13 '22 16:12 ratsclub

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).

JordanMarr avatar Dec 13 '22 19:12 JordanMarr

@NickDarvey did you find a solution for this?

I didn't, sorry @ratsclub

NickDarvey avatar Dec 14 '22 01:12 NickDarvey

@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 avatar Dec 14 '22 09:12 Thorium

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.

Thorium avatar Dec 20 '22 20:12 Thorium