Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework MVC4添加控制器错误_Entity Framework_Asp.net Mvc 4_Controller_Ef Database First - Fatal编程技术网

Entity framework MVC4添加控制器错误

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

尝试将控制器添加到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 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.0
public DbSet tblGames{get;set;}
建议您需要从“tblGames”而不是“Games”创建控制器