Search code examples
c#asp.net-mvcentity-frameworkvisual-studioasp.net-mvc-scaffolding

Failed to Add a New Scaffolded Item from a different Project into my Web Project (MVC 5)


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


Solution

  • 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.