What happens when I call Mapper.CreateMap with the same types multiple times?
Does it rewrite the previous map? If so, is it possible to make it throw an exception if I try to create map, that is already created?
What happens when I call Mapper.CreateMap with the same types multiple times?
Does it rewrite the previous map? If so, is it possible to make it throw an exception if I try to create map, that is already created?
When calling Mapper.CreateMap for the same set of source and destination several times, nothing will happen at all as the
Mapper.CreateMap<TSource, TDestination>()
does not set up any extensions for a mapping configuration. If you set the overrides for IMappingExpression like thisMapper.CreateMap<TSource, TDestination>().ConstructUsing(x=>new TDestination(x.SomeField))
, than yes, the configuration for this mapping will be replaced with the new one. Regarding the second part of your question, I know the way to verify if the map was already created: