简体   繁体   中英

Scaffolding an external model in ASP.NET MVC 5

I have a simple domain model in an external assembly. This model uses DTOs to communicate with a couple service classes. It does not use Entity Framework.

In Visual Studio 2012 I could select my DTOs in the Add View dialog and scaffold strongly-typed views for them.

Visual Studio 2012脚手架

However, the DTOs are not showing in the Add View dialog in Visual Studio 2013.

Visual Studio 2013脚手架

Strongly-typed views I create manually work just fine, so the issue isn't that Razor / MVC can't see or use my DTOs. The issue is just with the scaffolding.

Any help would be appreciated.

So your DTO lives somewhere other than the project namespace or the .Models namespace. The dropdown has an affinity to pull classes for strongly typed views from there. I realize that your DTOs might live in another assembly, and what your hack was, but is there a way to recompile them into the MvcDemo.Models namespace in the other assembly and declare a partial class in the models namespace in the MVC project? That may not be the ideal answer, and if you don't like the idea, I'll gladly delete my answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM