问题描述
所以我加载了一个旧项目来修复bug。
项目尝试运行初始化程序,但是这样做抱怨存在未决的数据库更改,或模型不正确等。
所以我的问题是:
1)为什么会这样当网站上线并且已经正常工作时,请求另外一个迁移被添加到运行成功吗?
2)为什么脚手架已经存在的迁移? br />
我尝试过:
在控制台中添加迁移,它支持迁移。然而,新的脚手架迁移与预先存在的Intial_Create迁移完全相同(这是1和唯一的迁移)。
So i loaded up an old project to fix a bug.
The project tries to run the initialiser, but upon doing so complains that there are pending database changes, or the model is incorrect etc.
So my questions are:
1) Why is it requesting another migration to be addded to run succesffuly, when the site has gone live and already works fine?
2) Why is it scaffolding a migration that already exists?
What I have tried:
Add-Migration in the console, and it scaffolds the migration. However the newly scaffolded migration is exactly the same as the pre-existing "Intial_Create" migration (this is the 1 and only migration).
推荐答案
Enable-Migrations
这将再次生成迁移文件夹
然后在Nuget Con再次点火命令......
This will generate again the migration folder
Then again fire command in Nuget Con...
Add-Migration 'with any message'
这将推动事物如果有任何待定的更改那么
然后再次点击最后一个命令
This will push things if any pending changes there
then again fire last command
Update-Database
现在你的Ef又好了回来
Now ur Ef is OK back again
这篇关于为什么代码首次迁移EF要求创建新迁移,何时已存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!