This guide helps troubleshoot Entity Framework Core migration issues.
The database has migrations that haven't been applied yet.
Solution: Run migrations:
dotnet ef database update
A table or column already exists in the database.
Solutions:
dotnet ef migrations script and apply manuallyThe database schema doesn't match your model.
Solution: Create a new migration:
dotnet ef migrations add FixModelMismatch
dotnet ef database update
| 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 |