[英]The Update-Database Add-Migration loop
I thought I figured it out when I disabled AutomaticMigrations. 我以为我在禁用AutomaticMigrations时知道了。
I Update-Database then Add new column name to DAL class. 我更新数据库,然后将新的列名称添加到DAL类。
Then execute Add-Migration 然后执行添加迁移
But I am caught in a loop of nonsense. 但是我陷入了胡说八道。
I execute Update-Database and am treated to ... Applying explicit migrations: [a list of the current migrations]. 我执行Update-Database,并被视为……应用显式迁移:[当前迁移的列表]。
then this line for each migration. 然后此行用于每次迁移。 Applying explicit migration: [id]
应用显式迁移:[id]
Then it warning me that the model is NOT up to date. 然后它警告我该模型不是最新的。 So I execute Add-Migration and get the error... Unable to generate an explicit migration because the following explicit migrations are pending: [the same list I just saw applied]
因此,我执行Add-Migration并收到错误...无法生成显式迁移,因为以下显式迁移正在处理中:[与我刚刚看到的相同列表相同]
WTF? WTF?
I resolved this through the following steps. 我通过以下步骤解决了这个问题。
Good luck if you run into this problem. 如果遇到这个问题,祝您好运。
I further ran into problems when I added code that explicitly called the initializer to speed up startup time. 当我添加显式调用初始化程序以加快启动时间的代码时,我进一步遇到了问题。 Then whenever I did an update-database...it would use my context class, try to do the initializer and fail.
然后,每当我执行更新数据库...时,它将使用我的上下文类,尝试执行初始化程序并失败。
Code-First is a good step in the right direction but it has all these be careful scenarios. 代码优先是朝正确方向迈出的良好一步,但它具有所有这些谨慎的方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.