EF 6 Code First Migration after deleting data from __MigrationHistory table

asp.net-mvc entity-framework entity-framework-6

Question

I attempted to migrate new tables and make column modifications to the database after I unintentionally erased data from the __MigrationHistory table. EF6 is now displaying an error to me.

"There is already an object named 'xxxx' in the database.".

I tried using this command to alter the table columns, but it had no impact.

Add-Migration MyMigration1 -IgnoreChanges
Update-database -Force

There are several suggestions for replicating a database or anything else. However, such methods could result in data loss in my database, which has a large amount of tested data and I am unable to lose any data. how to fix the issue without erasing any data. Please, if anybody...

Update

Finally I found the solution to solve my problem. I'm not sure whether that's the best approach to handle these kinds of issues, but it has for me.

When I attempted to migrate a new database and transferred data from the new database's __MigrationHistory to my old database, the issue was fixed. I then set AutomaticMigration true and ran the update-database command.

1
0
9/7/2018 7:25:20 AM

Popular Answer

ZZZ_tmp
0
9/5/2018 7:28:55 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow