EF Core 6 RC1 breaks extensions due to a change in a contract
See original GitHub issueFile a bug
After updating my project to EF Core 6 RC1, extensions installed with the project stopped working due to a contract change:
public abstract class DbContextOptionsExtensionInfo {
....
public abstract long GetServiceProviderHashCode();
}
public abstract class DbContextOptionsExtensionInfo {
....
public abstract int GetServiceProviderHashCode();
}
GetServiceProviderHashCode
has a new return type of int
rather than long
. This causes the following exception in production when loading an extension that was compiled against a previous EF Core version:
System.TypeLoadException: 'Method 'GetServiceProviderHashCode' in type 'ExtensionInfo' from assembly 'EntityFrameworkCore.Projectables, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fc5550082a9c642c' does not have an implementation.'
A simple reproduction using: EntityFrameworkCore.Projectables:
var serviceProvider = new ServiceCollection()
.AddDbContext<ApplicationDbContext>(options => {
options
.UseSqlite(dbConnection)
.UseProjectables() // Include our custom extension
})
.BuildServiceProvider();
// Causes System.TypeLoadException when targeting EF Core 6 RC1. Runs fine when targeting EF Core 6 preview 7 or earlier (including EF Core 5 and 3.1)
var dbContext = serviceProvider.GetRequiredService<ApplicationDbContext>();
EF Core version: 6.0.0-rc.1.21451.13 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET 6.0 RC 1) Operating system: Windows IDE: (e.g. Visual Studio 2022 17.4)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Breaking changes in EF Core 6.0
Complete list of breaking changes introduced in Entity Framework Core 6.0.
Read more >Ef core 6 breaking changes. Replace this call in 'MyFunction (s
In an attempt to correct many perceived deficiencies in Entity Framework Core, Microsoft is introducing 40 breaking changes to EF Core 3. This...
Read more >Breaking changes in EF Core 7.0 (EF7)
Complete list of breaking changes introduced in Entity Framework Core 7.0 (EF7)
Read more >EF Core 2.1 RC 1 GroupBy still evaluates locally
In my case the grouping was evaluated client-side for this query: await context.MyCollection .GroupBy(x => x.Tag.Id) .
Read more >My ASP.NET 5 migration to .NET 6
I spent the last few days migrating our ASP.NET REST services, MVC web applications and Blazor server apps to .NET 6.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, I understand that your proposal allows extensions to work with EF Core 6 without fixing the original issue. But this issue is hard to debug and workaround when it happens, so we decided to take a break and fix it for good this time.
Note that 3.1 and 5.0 will go out of support next year: Releases
@koenbeuk It’s more involved than that. I already discussed with @AndriySvyryd whether there was a reasonable way to avoid this. He can explain more if you want to pursue this.