Reputation: 5518
While working in ASP.NET MVC, I often find myself defining a basic ViewModel which all properties are but a small subset of the actual Entity model. I then use AutoMapper to transform my objects properly into and out of the Entity model. This works great, and separates my concerns nicely. However, I'm thinking that someone by now has made a tool to make this process easier! All the repetitive typing while creating my ViewModels inevitably leads to typos and some frustration.
What tools, if any, do you use to address this issue?
Thanks!
Edit: I don't mind decorating my properties with the appropriate UI hints, validators, etc. I just hate defining the same propery names again and again!
Upvotes: 1
Views: 1919
Reputation: 4770
You could consider using T4 templating, see this MSDN magazine article to get started. You could create a template that uses reflection to get the properties of your Model, and generate ViewModel from this.
Upvotes: 3