实体框架迁移停止检测 POCO 更新
我正在使用实体框架和实体框架迁移来实现使用代码优先和自动迁移的解决方案。
它曾经工作得很好,但突然停止检测我对 POCO 所做的更新。现在,当我添加一个新属性(非常简单的属性,如年龄或电子邮件)并执行 Update-Database
时,什么也没有发生,它给了我这个:
指定“-Verbose”标志以查看迁移期间正在执行的 SQL 命令。
发现 0 个待处理的显式迁移:[]。
添加种子数据(如果在迁移设置类中重写种子方法)。
并且没有任何更新!
有谁知道为什么会发生这种情况?
I'm using Entity Framework and Entity Framework migrations to implement solution using code-first and automatic migrations.
It used to work great but suddenly it stopped detecting the updates I make to my POCO. Now when I add a new property (very simple properties like age or email) and execute the Update-Database
, nothing happens, and it gives me this:
Specify the '-Verbose' flag to view SQL commands being executed during migration.
Found 0 pending explicit migrations: [].
Adding seed data (if Seed method overridden in Migrations Settings class).
and nothing gets updated!
Has anyone any idea why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能有两个原因:
一般来说,自动迁移实现起来简单、快速,但使用起来并不安全。在某些阶段,此类迁移可能会失败。
几年前,我开发了基于 Linq2SQL 的小型 ORM,AcroDB 库,它使用 < a href="http://subsonicproject.com/" rel="nofollow">SubSonic。与 EF 迁移现在可以做的几乎相同。它对于小型项目和需要处理或更改的少量数据来说是完美的,但是当项目增长到 15 个以上的表时,它就变成了一场噩梦。这就是为什么 MS 宣布 代码驱动的迁移 最近。他们对项目更有保障,也更好。另外,您可以查看 Migrator.Net (它比 EF 好一点,到这个时候)。
This may be in two reasons:
In general, automatic migrations are simple and fast to implement, but it is not secured to use them. On some stage, such migrations could make a fail.
Several years ago, I have developed tiny ORM based on Linq2SQL, AcroDB Library, and it was using automigrations of SubSonic. Almost same as EF migrations can do now. It was perfect on small projects and small amount of data to process or change, but when project has grow into 15+ tables, it became a nightmare. That's why MS has announced Code-driven migrations lately. They are more secured and better for the project. Also, you can take a look to Migrator.Net (it is a bit better than EF, by this time).