日期:2014-05-17  浏览次数:20434 次

MVC 3.0 遇到问题了
错误:The model backing the 'MovieDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data. 


看教程说 可以改变模型类的属性 或添加,,有2方法
1 自动重新创建
2 是手动去数据库改

但是 我手动改后 还是包这个错误 怎么回事????

------解决方案--------------------
你怎么手动修改的,最好能贴代码
------解决方案--------------------
手动更改需要重新维护ModelHash。

建议还是用SetInitializer自动初始化下。

加上Database.SetInitializer<UserDB>(new DBInitializer());

新建一个类:
class DBInitializer : DropCreateDatabaseAlways<UserDB>
{
protected override void Seed(UserDB context)
{
base.Seed(context);
}
}