I'm needing to do some mapping between objects (e.g. PersonModel to PersonViewModel) and am researching on the different approaches to do this. Specifically I'm working with Entity Framework and trying to map the generated models to a viewmodel.
However, I've yet to find an article or resource that compiles a list of how you can do this. So far, I've come across the following:
- Implicit Conversion (I think this is the most basic approach? since you manually map properties from one object to another, its simple but tedious)
- Extension Methods (haven't worked with this yet)
- Reflection (I've tinkered a bit, but only managed very basic mapping)
- Automapper (VERY popular, but I'm having trouble making it work well with EF)
- Value Injecter (haven't worked with this yet)
- Emit Mapper (haven't worked with this yet, but probably I would have trouble making it work with EF?)
Can you please help point out and elaborate on the approaches available there, as well as pros / cons of each? For example, I saw some that mentioned Automapper is slow compared to manual mapping? Or possibly, point out an article that tackles this?
EDIT: since some may ask what problem I have with AutoMapper, please see this: Automapper: How to map IList to EntityCollection