I am having an issue using AutoMapper (which is an excellent technology) to map a business object to a DTO where I have inheritance off of an abstract base class within a co
I've just faced the same problem with mapping dynamic EF proxies to ViewModels in MVC application.
I found an easy solution using Mapper.DynamicMap() for this problem. Here is my code:
Converting from Dynamic proxy to ViewModel class:
// dynamic proxy instance
WebService webService = _repWebService.GetAll().SingleOrDefault(x => x.Id == id);
//mapping
FirstStepWebServiceModel model = Mapper.DynamicMap(webService);
Converting from ViewModel class to EF Dynamic Proxy:
[HttpPost]
public ActionResult FirstStep(FirstStepWebServiceModel input)
{
// getting the dynamic proxy from database
WebService webService = _repWebService.GetAll().Single(x => x.Id == input.WebServiceId);
// mapping the input ViewModel class to the Dynamic Proxy entity
Mapper.DynamicMap(input, webService);
}
Hope this example help you