I can’t get this to work:
Mapper.CreateMap<Source, Destination>();
var context = new MyDbContext();
var source = new Source();
var destination= context.Destinations.First();
Mapper.Map<Source, Target>(source, destination)
Throws: AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
This works:
Mapper.CreateMap<Source, Destination>();
var source = new Source();
var destination= new Destination();
Mapper.Map<Source, Target>(source, destination)
The entity framework is creating a dynamic proxy class for my Destination class is that the reason it doesn’t work?
Without destination parameter it works as well i.e.:
var destination = Mapper.Map<Source, Target>(source);
This one is a bug and is fixed on the develop branch of AutoMapper. The prerelease version of AutoMapper has the fix, or wait a little bit for the 2.2.1 release.