简体   繁体   English

所有迁移文件和记录均已删除

[英]All migration files and Records was deleted

I did a big mistake with my project 我的专案犯了个大错误

i'm using EF 6.0 for my project in C# with manual migrations. 我正在使用手动迁移在C#中为我的项目使用EF 6.0。 for some reasons i deleted all migration files from my project and all migration records from __MigrationHistory table. 由于某些原因,我从项目中删除了所有迁移文件,并从__MigrationHistory表中删除了所有迁移记录。

i want to add a new migration to update the database with the new changes (many changes) on data model entities. 我想添加一个新的migration以使用数据模型实体上的新更改(许多更改)来更新数据库。

i don't want to lose my data. 我不想丢失我的数据。 so i cannot delete my database and create another one. 所以我无法删除我的数据库并创建另一个数据库。

Any help will be greatly appreciated 任何帮助将不胜感激

I'm not sure if there's a better solution, but this could help: 我不确定是否有更好的解决方案,但这可能会有所帮助:

  1. Rename your existing database. 重命名现有数据库。
  2. Add a new migration, it will create a new database. 添加一个新的迁移,它将创建一个新的数据库。
  3. Use the SqlServer Tools of Visual Studio, and compare the schema of the New Database to the Old Database. 使用Visual Studio的SqlServer工具,并将新数据库的架构与旧数据库进行比较。
  4. Use the SqlServer Tools of Visual Studio, and compare the data of the New Database to the Old Database (Copy the migration history table). 使用Visual Studio的SqlServer工具,将新数据库的数据与旧数据库进行比较(复制迁移历史记录表)。
  5. Delete the new database. 删除新的数据库。
  6. Rename the Old Database using its previous name. 使用旧名称重命名旧数据库。

It should be done for all developers. 应该为所有开发人员完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM