Why I can't get Entity Framework Migration to initial state?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 21:14:47

Here's a answer. Please recover migration folder and its migrations file (recover to your project). Then follow steps from my theard http://pawel.sawicz.eu/entity-framework-reseting-migrations/

1) Update-Database -Targetmigration:0 - it's the key! first
2) Wipe out tables/migrations (you dont have to delete whole folder)
3) Add-Migration Initialise
4) Update-Database

James Moss

Try these commands Sqllocaldb.exe stop V11.0 Sqllocaldb.exe delete V11.0

This should remove the reference. You may have to comment out some of the changes before doing this and then re-instating the changes back into model before doing the migration.

I'm new at this, so hopefully I am understanding your problem, because it sounds like the same one I encountered recently.

A more permanent solution may be to add the following code to your Globel file and replace the with what you need it to be. The article for this can be found at the link below also:

Database.SetInitializer(new DropCreateDatabaseIfModelChanges<PersonContext>()); 

http://ilmatte.wordpress.com/2012/12/05/entity-framework-5-code-first-enabling-migrations-in-a-real-project/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!