Search code examples
c#asp.net-mvcentity-framework-6asp.net-mvc-scaffolding

How to use referenced assembly for controller scaffolding


I have a class library with some model classes and a DbContext class (all those classes are public). This class library is referenced by an MVC-5 application.

Is it possible to use the model classes from that referenced class library for scaffolding of a controller in that MVC-5 application?

When I use Controllers - Add - Controller - MVC Controllers with views, using Entity Framework then in the dialog both comboboxes for Model class and for Data context class do not contain any items. When I fill in the fully qualified name of the class from referenced class library, then the Add button is still disabled. What am I doing wrong?

enter image description here


Solution

  • Scaffolding with referenced assemblies compiled as dll-file simply doesn't work. It was necessary to add reference to the project which contains the model classes. Then it worked as expected. Is this a bug or a feature?