Entity Framework Core Interview Question #82
How do you remove the last EF Core migration?
Migrations, Database Schema & Data Management Mid-Level Intermediate
Quick Interview Answer
If the most recent migration has not been applied where it matters and no later migration depends on it, EF Core tooling can remove that migration and update the model snapshot.
Detailed Explanation
If the most recent migration has not been applied where it matters and no later migration depends on it, EF Core tooling can remove that migration and update the model snapshot.
Removing a migration is different from reverting an already deployed production schema. Once a migration has been shared or applied to important databases, changing history can create inconsistencies.
In shared environments, it is usually safer to create a new corrective migration rather than rewriting published migration history.
Code Example
# Package Manager Console
Remove-Migration
# CLI equivalent
dotnet ef migrations remove