Skip to content

Could not load type 'SqlGuidCaster' from assembly Microsoft.Data.SqlClient #33430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aj-scram opened this issue Mar 29, 2024 · 7 comments
Closed

Comments

@aj-scram
Copy link

Recently upgrade project from .net7 to .net8 and immediately ran into this old dotnet/SqlClient#1930

Seems that the root cause is any older version of Microsoft.Data.SqlClient (<5.2.0) than the newest release not playing well with reflection calls loading types/assemblies.

Could we get Microsoft.EntityFrameworkCore.SqlServer to update to use the new version?

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 29, 2024

Not going to happen, as 5.2 is not LTS and .NET 8 is. You can just add an explicit reference.

@aj-scram
Copy link
Author

aj-scram commented Mar 29, 2024

Then can the dotnet team work internally to backport the fix to a 5.1.6 release? This is a major and long-standing breaking issue for those trying to migrate their projects; it seems unreasonable to me to have us work around it on our end.

@ajcvickers
Copy link
Contributor

We're actually going to revert to an older release for EF Core 9, since we can't take a dependency on a non-LTS version. So EF Core won't depend on anything above 5.1 until at least EF Core 10.

@AndriySvyryd AndriySvyryd closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@rasmusrim
Copy link

Not going to happen, as 5.2 is not LTS and .NET 8 is. You can just add an explicit reference.

Could I ask you to explain how to do that? Thanks!

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 24, 2024

@rasmusrim

Add this to your .csproj file that reference the EF Core SQL Server provider:

<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />

@aj-scram
Copy link
Author

Not going to happen, as 5.2 is not LTS and .NET 8 is. You can just add an explicit reference.

Could I ask you to explain how to do that? Thanks!

https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution#direct-dependency-wins

For doc reference

@amircliper
Copy link

@rasmusrim

Add this to your .csproj file that reference the EF Core SQL Server provider:

<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />

Thank you for sharing this solution! I ran into the same issue and confirmed that adding the following to the .csproj file resolves it:
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
Tested and worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants