Reputation: 187
I have the following scenario-
I am working in a branch where I have added 3 new migrations - for convention I will name them
Migration A
Migration B
Migration C
When trying to merge with master
it turns out there are 4 new migrations, that are not chronologically ordered (merged from another branch). What I mean is the following
new Migration from master 1
existing Migration in both branches
existing Migration in both branches
new Migration from master 2
new Migration from master 3
new Migration from master 4
existing Migration in both branches
existing Migration in both branches
And when merging I get the following scenario
new Migration from master 1
existing Migration in both branches
existing Migration in both branches
new Migration from master 2
new Migration from master 3
new Migration from master 4
existing Migration in both branches
existing Migration in both branches
Migration A
Migration B
Migration C
Now obviously Entity Framework will not let me update the database since it thinks the model is wrong - when adding a new migration it generates the changes from the aforementioned 4 new migrations from master
.
The real problem is that I can not revert back to an existing migration and then re-scaffold to update the metadata since they are not chronologically ordered (as suggested per accepted answer in another question).
I have tried to update-database -target
back to the migration before new Migration from master 1
and then Add-Migration <timestamp> new Migration from master 1
to re-scaffold it but I get the Unable to generate an explicit migration because the following explicit migrations are pending....
exception.
I do not really want to add a blank migration to fix this but rather find a clean and good solution to this.
Upvotes: 2
Views: 1851
Reputation: 187
After some more research the solution was to update database to the migration before the last one and then re-scaffold the last migration.
update-database -target Migration B
add-migration <timestamp>_Migration C
Upvotes: 2