我使用的是 Visual Studio 2012。我创建了一个 Class 项目并将 EF 数据模型添加到这个项目中。我从现有的 SQL Server 数据库创建了数据模型。我创建了一个 MVC 4 项目,向 web 配置添加了实体连接字符串,并添加了数据项目引用。
到目前为止一切都很好。
现在我想使用 Entity Framework 添加一个 MVC Controller 。我选择了一个模型类。我选择数据上下文类。单击添加。
VS 弹出一个错误,错误消息的最后一部分是类可能在已编译的程序集中{这是真的}。
'AA' is not part of the specified 'aanamespace.aaEntity' class and the entity class could not be modified to a DbSet property to it. For example the 'aaEntity' might be in a compiled assembly
最佳答案
我处于同样的情况,我创建了一个类库,其中包含我所有的 .edmx,当我引用我的 mvc 项目时,我得到了完全相同的错误消息,我在这里发布了我的问题(stackoverflow.com/问题/18552864/...)
我是如何修复的:
关闭 Visual Studio 并再次打开它...
关于asp.net-mvc - Entity Framework MVC Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13437656/