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.

Jordan Kelley
  • 23
  • 1
  • 4

3 Answers3

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.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • 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 – Jordan Kelley Feb 24 '15 at 20:42
  • 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. – Chris Pratt Feb 24 '15 at 20:49
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.

Jordan Kelley
  • 23
  • 1
  • 4
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

Debabrata
  • 63
  • 10