I am using Entity Framework 5.0 Data migrations along with code first. When i add a new field to my model and execute the following command in the package manager console.
Just got the same problem but figured out that my new field was added as a member variable and not a property - it was missing the {get; set;} part and that makes migration skip that field.
May not be your case but it might help someone else.
If you are using fluent api to set up your configurations for the DbSets then you won't have any problems with it
I had a problem similar to this, where using the -force
flag on add-migration
to re-scaffold an existing migration stopped working for no apparent reason.
No matter what I did I got the stupid "Unable to generate an explicit migration because the following explicit migrations are pending" error message. After trying nearly everything I could think of and stopping just short of smashing my laptop to pieces, out of desperation I ran enable-migrations
again and of course got the "Migrations have already been enabled in project 'Blah.Blah'" message. Tried add-migration -force
again and magically it was working.
I have no idea what it changed- must have been some user settings/config file outside of source control. Hopefully this will help someone else.
It seems that i managed to solve the problem by moving the models and the context class to another project.
I still have no idea why this happened, and this solution is really no solution at all :(