I have an ASP.NET MVC 3 (Razor) application that references an assembly where the assembly is nothing more than a bunch of entities that I use in my business logic.
I'm creating strongly-typed views by referencing entities/models that exist within my reference BL assembly. Unfortunately, by referencing models in this way, the scaffolding feature doesn't work - Specifically, MVC will create the View
successfully, but will not include any of the scaffolding of the exposed properties that live on the referenced model.
The only way I was able to get scaffolding to work was to explicitly create a class within the Models
directory that inherits from the entity and explicitly define properties similar to this:
Model Example
namespace MyMvcApplication.Models
{
public class MyMvcModel: MyReferencedEntity
{
new public string Name { get { return base.Name; } }
new public string Password { get { return base.Password; } }
new public string Foo { get { return base.Foo; } }
new public string Bar { get { return base.Bar; } }
}
}
Now if I reference the above model when I create a strongly-typed View, the scaffolding feature works great and all is well.
My question is; Is there a way I can get scaffolding to work on a View
that references a class that doesn't live in the Models
directory so that I don't have to recreate the class like I did in the above example?