microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
347 stars 20 forks source link

DacServices not Work with SqlClient 5.0 #126

Closed tomhafner closed 2 years ago

tomhafner commented 2 years ago

System.TypeInitializationException HResult=0x80131534 Nachricht = The type initializer for 'Microsoft.SqlServer.Dac.DacServices' threw an exception. Quelle = Microsoft.SqlServer.Dac Stapelüberwachung: bei Microsoft.SqlServer.Dac.DacServices..ctor(String connectionString) bei SuperLoad.Program.Update() in D:\GIT\SuperLoad\SL\Program.vb: Zeile5754 bei SuperLoad.Program.Init(String[] CmdArgs) in D:\GIT\SuperLoad\SL\Program.vb: Zeile194 bei SuperLoad.Program.Main(String[] CmdArgs) in D:\GIT\SuperLoad\SL\Program.vb: Zeile68

Diese Ausnahme wurde ursprünglich von dieser Aufrufliste ausgelöst: Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState.RegisterModelSchema() Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState.SqlSchemaModelStaticState()

Innere Ausnahme 1: TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception.

Innere Ausnahme 2: TypeLoadException: Could not load type 'Microsoft.Data.SqlClient.Server.Format' from assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.

ErikEJ commented 2 years ago

@tomhafner Expected, as there are breaking changes in 5.0

DavidWiseman commented 2 years ago

I get a similar error. This occurs when calling DacPackage.Load

System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacPackage' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacServices' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception.
 ---> System.TypeLoadException: Could not load type 'Microsoft.Data.SqlClient.Server.Format' from assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.RegisterImplementationForSqlModelImpl(ModelSchema storeSchema)
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState.RegisterModelSchema()
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.SqlSchemaModelStaticState.get_ModelSchema()
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.get_ModelSchema()
   at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlSchemaModel.InitializeModelSchema()
   at Microsoft.SqlServer.Dac.DacServices.Initialize()
   at Microsoft.SqlServer.Dac.DacServices..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Dac.DacServices.Initialize()
   at Microsoft.SqlServer.Dac.DacPackage..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Dac.DacPackage.Load(String fileName)

Thanks, @ErikEJ - I'll wait until a fix is available before I upgrade to 5.0.

kisantia commented 2 years ago

This is being worked on. We'll have more to share soon.

scottcurrie commented 2 years ago

Have y'all considered adding an upper bound on the version range for the SqlClient dependency in the DacFx nuget packages? That would have saved our team quite a bit of time debugging this issue.

dzsquared commented 2 years ago

linking additional dependent item on DacFx with MDS 5 - https://github.com/ErikEJ/EFCorePowerTools/issues/1345

llali commented 2 years ago

we just released a preview version of dacfx with MDS5. https://www.nuget.org/packages/Microsoft.SqlServer.DacFx/161.6304.0-preview

Please give it a try and let me know if you still have problems

BastienPerdriau commented 2 years ago

It seems to work on my side with this new preview version of DacFx and SqlClient nuget with version 5.0.0.

EDIT : As of now, I will wait for a stable NuGet version of this package to really upgrade in production.

ErikEJ commented 2 years ago

The latest daily build of EF Core Power Tools uses the 161 preview build with EF Core 7, and it works as expected.

BastienPerdriau commented 2 years ago

Hi.

Do you have any ETA for a stable version of the package, including this fix ?

ghost commented 2 years ago

The preview version works with Microsoft.Data.SqlClient version 5.0.1 as well.