I frequently encounter the following situation with Entity Framework code first migrations. I add some migrations and update the database with them successfully. When later I wish to add a new migration, the Add-Migration command complains that its "Unable to generate an explicit migration because the following explicit migrations are pending...". I.e., it seems to forget that its already applied those migrations previously and therefore they shouldn't be now considered as pending. If I try to workaround this issue, Update-Database indicates "Unable to update database to match the current model because there are [new] pending changes...". I don't understand why EF migrations getting out of sync since I'm only making changes to the model.
6
votes
Not sure how much it will help, but see this question/answer: stackoverflow.com/questions/16952413/…
- Steve
Thanks Steve. It appears this issue is caused by a VS 2013 bug in that VS 2013 doesn't properly update a DLL-reference (as opposed to a project-ref) when the reference is deleted and then added again from the database-context project's bin folder (even if Clean Solution is called in between). The referring project's bin doesn't show the updated database-context DLL even after subsequent compilation. Hence, the DLL's model is out-of-date with the database which has already been updated by the data-context project.
- CalvinDale
You should post that as an answer to your own question, so when others search for it they might find your explanation.
- Steve
4 Answers
13
votes
0
votes
0
votes