简体   繁体   English

使用实体框架脚手架错误添加带有视图的新 MVC 5 Controller

[英]Adding A New MVC 5 Controller with Views Using Entity Framework Scaffolding Error

When I try to add a MVC 5 controller with views using entity framework in my web app project, as it attempts to scaffold, I am getting this error:当我尝试在我的 web 应用程序项目中使用实体框架添加带有视图的 MVC 5 controller 时,当它尝试搭建脚手架时,我收到此错误:

"There was an error running the selected code generator: 'There was an error getting the type (name of entity model here).' “运行所选代码生成器时出错:'获取类型时出错(此处为实体 model 的名称)。” Try rebuilding the project."尝试重建项目。”

I did previously switch from MVC 4 to MVC 5, which perhaps could be at the root of this error.我之前确实从 MVC 4 切换到 MVC 5,这可能是这个错误的根源。 Any help is appreciated, thanks.任何帮助表示赞赏,谢谢。

Times when I've encountered something similar, I've been able to fix it by simply closing Visual Studio completely and re-opening the solution. 遇到类似问题的时候,我可以通过完全关闭Visual Studio并重新打开解决方案来修复它。 You should also make sure you rebuild your solution, if you haven't already tried the advice the error gives you. 如果还没有尝试过错误给出的建议,则还应确保重建解决方案。

So I am able to generate controllers and views via scaffolding if I first create a new data entity model, change my build configuration from x64 to x86, do a rebuild, clean the solution, and then restart Visual Studio. 因此,如果我首先创建一个新的数据实体模型,将构建配置从x64更改为x86,进行重建,清理解决方案,然后重新启动Visual Studio,则能够通过脚手架生成控制器和视图。

Frustrating that it comes down to that. 令人沮丧的是,归结为这一点。

This problem come because versions are different.出现这个问题是因为版本不同。 All Entity Framework package would be the same version and it will be work.所有实体框架 package 将是相同的版本并且可以工作。

Like:喜欢: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 实体框架5 MVC 4 - 脚手架错误 - 没有密钥 - Entity Framework 5 MVC 4 - Scaffolding Error - no key 使用实体框架脚手架和 Razor 对下拉列表进行 MVC 过滤 - MVC filter on dropdownlist using entity framework scaffolding and Razor MVC脚手架不支持Entity Framework 6或更高版本 - MVC scaffolding does not support Entity Framework 6 or later 如何使用MVC控制器和使用Entity Framework的视图来更改用户密码 - How to change users password using MVC controller with views using Entity Framework 使用实体框架添加具有读/写操作和视图的控制器会导致警告 - Adding a controller with read/write actions and views using entity framework results in a warning 使用实体框架添加具有读/写操作和视图的控制器 - 什么是“数据上下文类”? - Adding a controller with read/write actions and views, using Entity Framework - what is “Data Context class”? 如何在ASP MVC和实体框架中访问另一个控制器的视图 - How to access to views of another Controller in ASP MVC and Entity Framework 在实体框架中添加控制器时出错 - Error when adding a controller in Entity Framework 使用实体框架创建MVC4-Controller - Creating a MVC4-Controller using Entity Framework 使用实体框架添加具有新导航属性的新实体 - Adding New Entity with New Navigation Property Using Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM