Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have just upgraded my EF (identity) project to 9.0.6 and started running into the PendingModelChangesWarning error. In the process of debugging it I appear to have stumbled across what appears to be a bug in the implementation as it stands.
Not sure where this is most appropriate to log so I am going to log it both in EF core and the aspnetcore github.
Also this error message is awful, surely you can provide more information about specifically what is wrong?
Expected Behavior
No response
Steps To Reproduce
The bug appears to be very easy to reproduce.
Create a new database context
public sealed class DatabaseContextTest(DbContextOptions<DatabaseContextTest> options) : DbContext(options) {}
run your first migrations:
dotnet ef migrations add First_Migration
Run: await dbContext.Database.MigrateAsync();
Seems to work fine.
Modify this back to what I essentially had:
public sealed class DatabaseContextTest(DbContextOptions<DatabaseContextTest> options) : IdentityDbContext(options) {}
or more specifically
public sealed class DatabaseContextTest(DbContextOptions<DatabaseContextTest> options) : IdentityDbContext<ApplicationUser>(options) {}
public class ApplicationUser : IdentityUser {}
run your first migrations:
dotnet ef migrations add First_Migration
Run: await dbContext.Database.MigrateAsync();
and you get an exception.
Exceptions (if any)
An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.PendingModelChangesWarning': The model for context 'DatabaseContextTest' has pending changes. Add a new migration before updating the database. See https://aka.ms/efcore-docs-pending-changes. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
.NET Version
.NET 9
Anything else?
No response