8

When I try to create a New Scaffolded Item in my website project, I get the following message:

Error

There was an error running the selected code generator:

'There was an error getting the type 'SomeProjectInMySolution.SomeModelInThatProject'.

Try rebuilding the project.'

Now, It seems that is not able to create it because is in a different context.

I tried doing what this answer suggested. But, failed.

What else could I try?

This is how I am filling the generation form:

enter image description here

Note:

I am using:

  • Entity Framework6 6.1.3

  • EntityFramework Reverse POCO Code First Generator: to generate the context in that particular project where it exists.

  • All of my projects are buing built in 64-bit platform.

  • I also have the correct ConnectionString in my Web.config in the Website Project as well.

Thank you so much

Updates:

I also tried this. But, nothing.

I noticed that when trying to create the item, the console outputs this:

Attempting to install version '6.1.1' of 'EntityFramework' but the project already includes a different version. Skipping...

However, all my projects have 6.1.3. Tried downgrading to 6.1.1. But, still not working. Why is it even displaying that message?

<package id="EntityFramework" version="6.1.3" targetFramework="net451" />

DefaultAppPool Advanced Settings:

enter image description here

Community
  • 1
  • 1
Luis Lavieri
  • 4,064
  • 6
  • 39
  • 69
  • Have you rebuilt the project and tried again? –  Oct 21 '15 at 14:00
  • You can reference this link: http://stackoverflow.com/questions/29259374/scaffolding-auto-code-generator-completely-broken –  Oct 21 '15 at 14:06
  • Tried that as well. I also tried downgrading EntityFramework from 6.1.3 to 6.1.1. But, nothing. – Luis Lavieri Oct 21 '15 at 14:17
  • I remember running into this exact error message. I "rebuild" the solution and close/reopen visual studio and then it is running well. – Ppp Oct 27 '15 at 02:42
  • I've tried it already too many times :( but thanks for the suggestion. – Luis Lavieri Oct 27 '15 at 15:48
  • also try seeing this one http://stackoverflow.com/questions/20841831/there-was-an-error-running-the-selected-generator-try-rebuilding-the-project – bot Oct 29 '15 at 08:21

3 Answers3

3

I finally found the solution for this horrible problem:

Several posts were sure that it was related to the x64 platform thing. So, in a last and desperate attempt I just changed the platform to Any CPU (of every project), then I run the Scaffolded item generator, and then finally switched back 64-bit.

I am not sure why this works. My coworker mentioned that Visual Studio was built in 32-bit and maybe that's what caused the issue. I really don't know. But, I hope this helps anyone in the future with the same problem.

Thanks to everyone who tried.

Luis Lavieri
  • 4,064
  • 6
  • 39
  • 69
1

I had a similar problem with generating views from a controller in asp.net .

The problem here was, that my model class inherited from a class outside project, when i commented the inheritance out of the class, the generation worked and i was able to make the inheritance again.

like this:

public class Employee //: PersonBase {...}

so i generated and then i deleted the Comment slashes.

public class Employee : PersonBase {...}

Do not know if it helps you but it is worth a try.

Manuel Fuchs
  • 399
  • 4
  • 12
0

Just spent whole day with the same issue and it turns out to be a bug in MVC scaffolding which is already reported. For details and work around please see the link below: https://github.com/aspnet/Mvc/issues/4336

vipasane
  • 355
  • 2
  • 10