Logo

Migration Errors

This guide helps troubleshoot Entity Framework Core migration issues.

Common Errors

DATABASE_MIGRATIONS_PENDING

The database has migrations that haven't been applied yet.

Solution: Run migrations:

dotnet ef database update

Migration Failed - Object Already Exists

A table or column already exists in the database.

Solutions:

Model Mismatch

The database schema doesn't match your model.

Solution: Create a new migration:

dotnet ef migrations add FixModelMismatch
dotnet ef database update

Useful Commands

Command Description
dotnet ef migrations list List all migrations
dotnet ef database update Apply pending migrations
dotnet ef migrations add [Name] Create a new migration
dotnet ef database drop Drop the database