EF Data migrations won't detect changes when adding new migration

后端 未结 16 1898
情话喂你
情话喂你 2020-12-09 14:53

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.

16条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 15:23

    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.

提交回复
热议问题