简体   繁体   中英

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:

"There was an error running the selected code generator: 'There was an error getting the type (name of entity model here).' Try rebuilding the project."

I did previously switch from MVC 4 to MVC 5, which perhaps could be at the root of this error. 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. 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.

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.

Like: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM