What are the latest bugs and fixes in C# Entity Framework Core migrations in 2025 (.NET 9 / .NET 10)?

ykl
ykl
340 Points
17 Posts

I'm working on a multi-project ASP.NET Core 9 solution using Entity Framework Core and have been running into some migration-related issues after upgrading. I wanted to start a thread to collect the most common EF Core migration bugs developers are hitting in 2025 — especially around .NET 9 and .NET 10 upgrades.

Here are the issues I've personally encountered:

Bug #1 — EF Tools vs Runtime version mismatch

After upgrading to .NET 10 runtime, I get this warning:

The Entity Framework tools version '9.0.5' is older than
that of the runtime '10.0.0'. Update your tools.

Fix: dotnet add package Microsoft.EntityFrameworkCore.Tools --version 10.0.0

Bug #2 — Missing Microsoft.EntityFrameworkCore.Design package

Your startup project doesn't reference
Microsoft.EntityFrameworkCore.Design.

Fix: Add Microsoft.EntityFrameworkCore.Design to your startup project (not just the infrastructure project).

Bug #3 — Migration assembly mismatch in multi-project solutions

Your target project 'MyApp' doesn't match your migrations
assembly 'MyApp.Infrastructure'.

Fix: Use --project flag to specify the migrations project explicitly when running CLI commands.

Bug #4 — Deleted migration file causes Update-Database failure

The migration '20250301_BadMigration' was not found.
Check that the migration name is correct.

Fix: Roll back via Update-Database -TargetMigration:LastGoodMigration before removing files.

Have you hit any of these or other EF Core migration bugs in 2025? What version were you on and how did you fix it? Especially interested in experiences with .NET 10 and EF Core 10 upgrades.

Views: 12
Total Answered: 1
Total Marked As Answer: 0
Posted On: 29-Apr-2026 03:50

Share:   fb twitter linkedin
Answers
Smith
Smith
2964 Points
79 Posts
         

Great question! These are exactly the kinds of migration issues that trip up developers during .NET version upgrades. Here's a consolidated answer covering all four bugs with complete fixes and some additional tips from real-world experience.

Fix #1 — EF Tools vs runtime version mismatch

Always keep your Tools and Design packages on the same major version as your runtime. Run these in your startup project:

dotnet add package Microsoft.EntityFrameworkCore.Tools --version 10.0.0
dotnet add package Microsoft.EntityFrameworkCore.Design --version 10.0.0

Pro tip: When upgrading EF Core, treat ToolsDesign, and the core runtime packages as a single upgrade unit — never upgrade one without the others.

Fix #2 — Missing Design package

The Design package must be in your startup project, not just your infrastructure/data project. In your startup project's .csproj:

<PackageReference Include="Microsoft.EntityFrameworkCore.Design"
  Version="10.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

The PrivateAssets=all flag ensures it's a dev-only dependency and won't be published to production.

Fix #3 — Migration assembly mismatch (multi-project solutions)

Always specify both --project (where migrations live) and --startup-project (your API/web project) explicitly:

dotnet ef migrations add InitialCreate \
  --project src/MyApp.Infrastructure \
  --startup-project src/MyApp.Api

Also make sure your DbContext registration includes the migrations assembly:

options.UseSqlServer(connectionString, x =>
  x.MigrationsAssembly("MyApp.Infrastructure"));

Fix #4 — Safely removing a bad migration

Never manually delete migration files. Always follow this safe sequence:

Step 1: Roll back the database first
Update-Database -TargetMigration LastGoodMigration

Step 2: Then remove the bad migration file safely
dotnet ef migrations remove

If you already deleted the file manually, query __EFMigrationsHistory to find the last applied migration, then run Update-Database to that target to resync.

Bonus tip — never run migrations auto-apply in production

Avoid context.Database.Migrate() in your startup pipeline for production environments. Generate a SQL script instead and review it before applying: dotnet ef migrations script --idempotent

Quick reference checklist

Tools, Design, and runtime on same major version
Design package in startup project with PrivateAssets=all
Always use --project and --startup-project flags in multi-project solutions
Roll back DB before removing migration files — never delete manually
Use --idempotent SQL scripts for production deployments
Posted On: 29-Apr-2026 03:59
 Log In to Chat