小编Mic*_*ael的帖子

实体类型不是模型的一部分,EF 5

我正在尝试将我的存储库更新为EF5,但遇到了一些错误.我已经看了一下stackoverflow,因为类似的错误发现了一些问题/答案,但不幸的是,相同的答案并没有解决我的问题.

这是我的错误:

The entity type User is not part of the model for the current context.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Run Code Online (Sandbox Code Playgroud)

这是我的DbContext类:

public abstract class WebModelContext : DbContext
{
    public WebModelContext()
        : base("WebConnection")
    {
        Configuration.LazyLoadingEnabled = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是继承我的WebModelContext类的上下文类:

public class AccountContext : WebModelContext
{
    private DbSet<User> _users;

    public AccountContext()
        : …
Run Code Online (Sandbox Code Playgroud)

entity-framework dbcontext entity-framework-5

6
推荐指数
1
解决办法
2万
查看次数

VS 2012中缺少实体数据模型

添加新项目时,我无法在"数据"选项卡下找到实体数据模型.

我已经查看了几个问题和答案,有关这方面的信息,但没有一个解决方案有效.

我已经修复,卸载并重新安装,手动安装了EF Tools软件包,并尝试卸载所有与VS相关的程序.我还尝试在不同的.NET框架下创建几个新项目,类库,Web项目,但它不存在.

主项目:Visual Studio 2012,类库项目.NET 4.0

c# entity-framework visual-studio visual-studio-2012

3
推荐指数
1
解决办法
1万
查看次数