EF Code First(The model backing the '***' context has changed since the database was created.解决方法)(CSDN手动迁移)

错误消息:

The model backing the '***' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

错误原因:

(1)数据模型发生改变,而没有更新到数据库导致此问题。

事实上我遇到的情况不是原因(1),而是(2)造成的

(2)更新到数据库 用的EF 6.1.0 ,而数据访问层用的是EF 6.0.2

解决方法:

(1)用Code First  更新数据库,命令如下:

Add-Migration
Update-Database -Verbose

(2)数据访问层换成EF 6.1.0 ,问题解决

原文地址:https://www.cnblogs.com/hetring/p/4611231.html