I am mapping between two objects, the source contains two strings called Animal
and AnimalColor
, for instance Animal = "Cat"
and AnimalColor = "White"
. The destination contains a property Animal
which is a class of type Pet
which contains two strings, Type
And Color
Therefore I have the following in my mapper configuration:
cfg.CreateMap<SrcPetStore, DestPetStore>()
.ForMember(dest => dest.Animal, opt => opt.MapFrom(src => new Pet() { Type = src.Animal, Color = src.AnimalColor }));
When I run this I get an AutoMapperMappingException
complaining about Missing type map configuration or unsupported mapping
on mapping
String -> Pet
It's like it tries to map the destination Animal
(Pet object) from the source Animal
(string) without taking the custom ForMember configuration into account
If I add an unused mapping cfg.CreateMap<string, Pet>()
everything works but it shouldn't be necessary since that mapping is never used (and makes no sense)
This is in AutoMapper 5.0.