1

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.

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Chris, I gave that a try but no luck. I recently (around the same time of upgrading to MVC 5) created a fake dbcontext of my entity framework backend and am wondering if that perhaps might be also be behind this. My other controllers and views all work as normal, it's just the scaffolding of creating a new one where I am running into trouble
Well, the scaffolds are notoriously buggy. Personally, it didn't take long between issues like this and having to undo most of what the scaffold added anyways before I just dumped using them entirely. Ironically, it's much easier and fluid to just add the files and folders manually yourself as needed.
0

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.

Comments

0

This problem come because versions are different. All Entity Framework package would be the same version and it will be work.

Like: enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.