Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Add-Migration indicates "No pending explicit migrations" but Update-Database complains "..there are pending changes"

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.

like image 697
CalvinDale Avatar asked Nov 21 '13 01:11

CalvinDale


1 Answers

For me the issue was that we had renamed the namespace of the migration 2014123456_Initial.cs.
But VS had not regenerated the namespace in its associated 2014123456_Initial.Designer.cs.

Once the Designer.cs was changed to use the same namespace, it all started working again.

like image 130
demoncodemonkey Avatar answered Sep 19 '22 09:09

demoncodemonkey