scaffolding viewmodels based on database tables

2019-07-21 09:53发布

问题:

Is there anything that would aid us in designing/scaffolding View models from SQL Server database tables but would result in very lean classes? I know something like that exists for Rails, maybe there's something similar in ASP.NET MVC?

I like what EF wizard creates but it's too heavy - too much attributes, constraints, events and everything is attached to the entities so you can't actually use them as View models (actually you can but it quickly becomes a pain).

回答1:

I think you could use a POCO generator for your EF4 model instead of the default one. This is a link explaining how. LINK I hope you can adapt it to fill your needs.

A POCO Class(Plain Old CLR Objects) is by definition a lightweight class, that is (maybe) what you're looking for.