Entity Framework Core Interview Question #80
How can you list migrations and determine whether migrations are pending?
Migrations, Database Schema & Data Management Mid-Level Intermediate
Quick Interview Answer
EF Core tooling can list migrations known to the project, while application APIs can inspect applied and pending migrations for a database.
Detailed Explanation
EF Core tooling can list migrations known to the project, while application APIs can inspect applied and pending migrations for a database.
This is useful in deployment diagnostics when the application model and production schema may be out of sync.
Checking migration state should not replace a controlled deployment process, but it can help verify that the expected schema version is present.
Code Example
# CLI
dotnet ef migrations list
// Runtime inspection
var pending = await db.Database
.GetPendingMigrationsAsync();