Receiving "The model backing the 'Context' context has changed… on Add-Migration after EF 5 upgrade

♀尐吖头ヾ 提交于 2020-02-03 04:49:05

问题


We are building an app using code-first migrations. We had been using Entity Framework 5.0.0 RC, and we updated our NuGet package for Entity Framework. The database has been in sync with the models context. Code first migrations have been working fine for months.

When we modify our models, and try to add a migration, or even query for migrations, we receive the System.InvalidOperationException for the model backing changed.

Well, obviously it has, I'm trying to add a migration.

We're not sure what to do from here. If I remove the changes, I can run Get-Migrations successfully and it shows that the database has all the migrations applied correctly. Although the ProductVersion column says "5.0.0-rc.net45".

Has anyone else experienced this problem?


回答1:


Found it. The source of this problem was code that set the DbContext.CommandTimeout in our constructor for the same class, like in this other question. Accessing that property started an initialization process that was giving us the error of what the command we actually invoked was trying to solve.



来源:https://stackoverflow.com/questions/15169281/receiving-the-model-backing-the-context-context-has-changed-on-add-migrati

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!