EF Code First(提示The model backing the '***' context has changed since the database was created.)

来源:互联网 发布:数组和元组 编辑:程序博客网 时间:2024/05/17 22:28

错误消息:

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 ,问题解决

0 0