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

前端 未结 3 1889
梦如初夏
梦如初夏 2021-01-12 18:00

I am trying to update my repository to EF5 but have encountered a few errors. I\'ve taken a look around stackoverflow for similar errors discovered a few questions/answers b

相关标签:
3条回答
  • 2021-01-12 18:16

    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!

    0 讨论(0)
  • 2021-01-12 18:20

    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

    0 讨论(0)
  • 2021-01-12 18:26

    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>();
        }
    }
    
    0 讨论(0)
提交回复
热议问题