简体   繁体   English

EF代码优先迁移存储在哪里?

[英]Where are EF Code-First Migrations Stored?

My situation is this - I just corrupted my SQL database. 我的情况是这样-我刚破坏了我的SQL数据库。 The only backup I have is from a number of migrations ago. 我唯一的备份是以前的许多迁移。 Let's say I use the backup as my database now. 假设我现在将备份用作数据库。

How do I apply the recent migrations. 如何应用最近的迁移。 They have to be stored somewhere in the db...right? 它们必须存储在数据库中的某处...对吗?

I am not only asking for a fix, but interested in this theoretically - what exactly does Get-Migrations check? 我不仅要寻求解决办法,而且从理论上讲对此很感兴趣Get-Migrations究竟检查什么? What is checked when I run Update-Database ? 运行Update-Database时要检查什么? I know a Migration file gets added to the project directory. 我知道迁移文件已添加到项目目录。 But is it in the database somewhere too? 但是它也在数据库的某个地方吗?

Migrations are code(with resources for model snaphot) which should be executed to change your db. 迁移是代码(具有用于模型快照的资源),应执行该代码以更改数据库。 There is a table in db which tracks last applied migration (MigrationHistory). db中有一个表,该表跟踪上一次应用的迁移(MigrationHistory)。

Migrations are stored in the __MigrationHistory table of the database. 迁移存储在数据库的__MigrationHistory表中。

The Model column cintains a GZip-compressed XML string of you model. Model列包含您建模的GZip-compressed XML string

You can see the following page for a nice write up http://tech.trailmax.info/2014/03/inside_of_ef_migrations/ 您可以在下面的页面中找到不错的文章http://tech.trailmax.info/2014/03/inside_of_ef_migrations/

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

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