Entity framework MVC4添加控制器错误
尝试将控制器添加到WebUI时,出现以下错误:Entity framework MVC4添加控制器错误,entity-framework,asp.net-mvc-4,controller,ef-database-first,Entity Framework,Asp.net Mvc 4,Controller,Ef Database First,尝试将控制器添加到WebUI时,出现以下错误: 'DTO.Games' is not part of the specified 'DAL.GamesEntities' class, and the 'DAL.GamesEntities' class could not be modified to add a 'DbSet<DTO.Games>' property to it. (For example, the 'Dal.GamesEntities' class might be
'DTO.Games' is not part of the specified 'DAL.GamesEntities' class, and
the 'DAL.GamesEntities' class could not be modified to add a
'DbSet<DTO.Games>' property to it. (For example, the
'Dal.GamesEntities' class might be in a compiled assembly
“DTO.Games”不是指定的“DAL.gamessenties”类的一部分,并且
无法修改'DAL.GamesEntities'类以添加
将“DbSet”属性添加到它。(例如
“Dal.GamesEntities”类可能位于已编译的程序集中
在这里提问之前,我搜索了一个,但没有一个在线解决方案对我有帮助。我正在DBFirst工作。任何有助于解决这个问题的代码:提问,你就会收到
提前谢谢
代码
- Games.Context.cs(包含GamesEntities)——
DAL.GameEntities
@Guillelon添加了Games.context.cs,其中包含gamessenties你使用的是什么版本的实体框架?版本6的预发布导致MVC4中出现类似的情况。如果你使用的是EF6,你可能需要升级到MVC5。@melkisadek版本5.0.0public DbSet tblGames{get;set;}
建议您需要从“tblGames”而不是“Games”创建控制器