问题
Edit: I dropped the database. It still tells me the migration is applied. I don't buy your shit, EF...
I have 5 migrations, but the 5th has been created on accident. It doesn't hold any changes (Up
and Down
methods are empty). Without thinking I appied it to the database.
Now when I run dotnet ef database update migration4
it tells me it successfully reverted migration #5 and the table __EFMigrationsHistory
doesn't show an entry for migration #5. Upon trying to remove it with dotnet ef migrations remove
it tells me that migration #5 is still applied to the database and the entry in __EFMigrationsHistory
shows back up.
When rolling back to migration #3 with dotnet ef database update migration3
it does remove the changes from migration #4, and removes the entries from the __EFMigrationsHistory
table.
Now, when trying to remove, it just reapplies all the migrations. Same for reverting back to initial migration.
Any suggestions? I have no idea where to begin. Do I have to redo the whole database and/or migrations? I tried overriding migration #5 but dotnet ef migrations add
doesn't accept the parameters -f
or --force
.
回答1:
the better way is go to
PM Remove-Migration
PM Drop-DataBase
or delete your migration folder in your solution explore and create a new migration this will make your all 5 migration into one migration
PM Add-Migration
PM Update-Database
来源:https://stackoverflow.com/questions/51892239/ef-migrations-not-able-to-remove-migration