-
Notifications
You must be signed in to change notification settings - Fork 317
Closed
Labels
External 🔗Issue is in an external componentIssue is in an external component
Description
At runtime, when we invoke a db context method, e.g. SaveChanges, we are always getting an issue with the Microsoft.Data.SqlClient dependency.
A .NET 7.0 app, that has a dependency on Microsoft.EntityFrameworkCore.SqlServer
- tried almost every version of that package Microsoft.EntityFrameworkCore.SqlServer 7.0.0 - 7.0.10
- Have tried adding a direct dependency on Microsoft.Data.SqlClient, we can't go lower than 5.0.1 (for all versions of 7.0.x, so can never take a dependency on Microsoft.Data.SqlClient 5.0.0.0
- event went back to Microsoft.EntityFrameworkCore.SqlServer 6.0.21 (which has a dependency on Microsoft.Data.SqlClient 2.*, that also exhibited an unable to load file or assembly error on Microsoft.Data.SqlClient...
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7
The error only occurs in the Linux based App service, which is published using:
dotnet publish --os: linux
dotnet sdk version: 7.0.203
Target OS: Azure AppService
Same dotnet app / sdk works as expected on local developer Windows 10 machine.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified.
File name: 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
I did notice in the .deps. that get generated in the bin dir (on local dev windows 10) that there is some reference to a 5.0.0.0 (but I can't see any way to influence that):
"Microsoft.Data.SqlClient/5.1.1": {
"dependencies": {
"Azure.Identity": "1.7.0",
"Microsoft.Data.SqlClient.SNI.runtime": "5.1.0",
"Microsoft.Identity.Client": "4.48.1",
"Microsoft.IdentityModel.JsonWebTokens": "6.25.1",
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "6.25.1",
"Microsoft.SqlServer.Server": "1.0.0",
"System.Configuration.ConfigurationManager": "6.0.1",
"System.Diagnostics.DiagnosticSource": "6.0.0",
"System.Runtime.Caching": "6.0.0",
"System.Security.Cryptography.Cng": "5.0.0",
"System.Security.Principal.Windows": "5.0.0",
"System.Text.Encoding.CodePages": "6.0.0",
"System.Text.Encodings.Web": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Data.SqlClient.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
}
},
"runtimeTargets": {
"runtimes/unix/lib/net6.0/Microsoft.Data.SqlClient.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
},
"runtimes/win/lib/net6.0/Microsoft.Data.SqlClient.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
}
}
bricelam
Metadata
Metadata
Assignees
Labels
External 🔗Issue is in an external componentIssue is in an external component