MVC中EF代码优先问题

2021-06-24 04:03

阅读:482

标签: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


评论


亲,登录后才可以留言!