Entity Framework Code First Migration Class File

你说的曾经没有我的故事 提交于 2019-12-05 21:41:45

This is likely because you have a database initializer, that always keep the database in sync with the model, regardless of migrations.

Take a look at the __MigrationHistory and you'll likely see that the schema was updated by the MigrateDatabaseToLatestVersion initializer. The MigrationId will be something like 201307290913337_AutomaticMigration.

To fix it, delete the database, comment out the changes to your model, run Update-Database - now comment in the changes, and add the migration again.

If the last record of the __MigrationHistory table is indeed a xxxxxxx_AutomaticMigration one, you can just delete it and run Add-Migration again, and your migration class should have something useful in its Up and Down methods.

You should make sure that you run Add-Migration when the changes are not already made.

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