首页 > Web开发 > 详细

MVC中EF代码优先问题

时间:2017-07-13 12:28:50      阅读:332      评论:0      收藏:0      [点我收藏+]

在练习Mvc项目时,提示如下数据库错误:

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

按上述链接要求,在程序包管理控制台执行:Enable-Migrations 后,

生成对应DAL目录内生成 Mirgrations新目录,

再执行 Update-Database, 提示

Specify the ‘-Verbose‘ flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
You can use the Add-Migration command to write the pending model changes to a code-based migration.

项目仍无法连接数据库,

后直接清除数据库内的 [__MigrationHistory]表数据,

问题成功解决。

MVC中EF代码优先问题

原文:http://www.cnblogs.com/todayhero/p/7159776.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!