“自数据库创建以来,支持”上下文“的模型已经发生了变化 - 在不同的项目中 [英] 'The model backing the '' context has changed since the database was created' - in different project
问题描述
支持上下文的模型自数据库创建以来已更改。考虑使用代码优先迁移来更新数据库...
有什么可能发生的想法?
解决方案是:
- 将Entity Framework添加到每个项目
- 在您提出数据库的项目中添加Global.asax
-
在Application_Start中添加以下内容行:
Database.SetInitializer< namespace.Entities>(null);
其中 Namespace.Entities
是您的 DbContext
的地址。
I'm using EF with Code First Approach and I have a static method that is used for authentication. If I call it inside the project, it works fine, if I however call it from a different project I get the following error:
The model backing the '' context has changed since the database was created. Consider using Code First Migrations to update the database...
Any ideas why that might be happening?
The solution is:
- Add Entity Framework to each project
- Inside the project where you raise the database add Global.asax
Inside the Application_Start add the following line:
Database.SetInitializer< Namespace.Entities>(null);
where Namespace.Entities
is the address to your DbContext
.
这篇关于“自数据库创建以来,支持”上下文“的模型已经发生了变化 - 在不同的项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!