码迷,mamicode.com
首页 > Web开发 > 详细

MVC中EF代码优先问题

时间:2017-07-13 12:39:46      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:ase   管理   link   连接数据库   isa   statement   enable   包管理   app   

在练习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代码优先问题

标签:ase   管理   link   连接数据库   isa   statement   enable   包管理   app   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!