The entity type is not part of the model, EF 5

此生再无相见时 提交于 2019-12-01 05:24:34

EF may not be able to pick up the entity types you have declared. Override the OnModelCreating and add the User entity to model.

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

    public AccountContext()
        : base()
    {
        _users = Set<User>();
    }

    public DbSet<User> Users
    {
        get { return _users; }
    }

    protected virtual void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<User>();
    }
}

I have had the same problem with EF 5... What Ive done was to delete all files created by tt files and re-create them again... every thing was working again!

Your table model name is wrong. set the correct name when sates in Sql server. return View(db.tblEmployees.ToList()); error line.....

go Model and duble click ur model name than matching with table name like (tblEmployees)

your error is solve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!