6
votes

I have created an .Net Core MVC6 application targeting net461. I have used a project structure I am very familiar with in which I place the data, model, and service classes in separate class library projects and the Web project references these.

When I attempt to scaffold a controller I receive an error that multiple matching types exist for the model I am scaffolding.

If I move all code to a single project, scaffolding is successful. If I move the context to Web project and leave the model in a separate project, I receive an error the NO matching types were found.

Has anyone else seen this same issue? Is there a workaround to still use this type of architecture?

Update

I started another project and always get this issue. I get this error when only using 1 extra project for the models. Attached is the error I recieve.

Scaffolding Error

Update 2

When the context and model are in the same project I receive this error.

Error editing dbContext

1
Hi,not sure if related but probably not ,but I am having issues in calling classes located in a different project in same solution.Solution compiles but cannot call class as main project even though is referenced call see this class/assembly.Have you had the same issue? I put a project on github github.com/developer9969/ProjToProjReference.developer9969
@developer9969 Do you have resharper? If so, do you have build errors or just intellisense? Resharper does not fully support rc2 yet. blog.jetbrains.com/dotnet/2016/05/27/…David Newberry
yes I have resharper the solution compiles but if I try to call the class on a project within solutions I can't because visual studio doesn't show me the new class in either in the using statements or by instantiating it.developer9969
yes you are right disabled resharper and my intellisense now works.It fooled me for all weekend.GRRRRRR.THANKS!developer9969
@developer9969 On a side note I didn't fully disable Resharper. I just added the Views folder to the ignore list in Resharper => Options => Code Inspection => Settings => Elements to skip. This seems to work fine and lets me use other Resharper features such as conver to LINQ and etc.David Newberry

1 Answers

10
votes

Cannot post a comment, so I've to write an answer instead. I also had the same issue and opened it on Scaffolding github repository. Here's the response:

currently there is an issue with scaffolding, that it doesn't support model classes outside of the current project properly.

As a workaround, you can add the model temporarily to your web project and then move it to the BLL/ DAL projects after scaffolding.

Plus they also opened this issue as a bug, quoting:

Scaffolding fails if model class is in a dependency (project/ library) of the project on which scaffolding is being run. #251

Project A has a dependeny on Project B. Project B has model class If you try to run scaffolding on Project A by using model class from Project B, it fails with the below error: No model type returned for type:

Hence, as of RC2, this is a bug in scaffolding tooling.