EF Core remove applies not runned migrations

Viewed 442

Im trying to remove a migration that went wrong. I have the following migrations: InitialMigration MyBadMigration

First my database state is at InitialMigration.

  • I then run "dotnet ef migrations add MyBadMigration"
  • I then run my application which updates the database with dbContext.Database.Migrate();
  • My database is updated to the new state.
  • I then realize that my migration is bad and I want to revert the changes.
  • I apply "dotnet ef database update InitialMigration" and I can see that my database is reverted.
  • I then want the snapshot and MyBadMigration.cs to be reverted so
  • I apply "dotnet ef migrations remove"
  • The database is then updated to MyBadMigration once more and I cant remove the migration.

If I use "dotnet ef migrations remove -f" when in InitialMigration the sourcefiles is updated (snapshot is reverted and MyBadMigration.cs is deleted) bu the database is still in the new state.

I use .net core 2.0 and ef core 2.0

0 Answers
Related