2
votes

I use Automapper in many locations in the code in my solution. But I don't understand why in one project of this solution, I do this :

Mapper.CreateMap<MY_CLASS, MyClass>();

Mapper.AssertConfigurationIsValid();

var result = Mapper.Map<List<MY_CLASS>, List<MyClass>>(myListResult);

I get this exception on the Mapper.Map line : Missing type map configuration or unsupported mapping

In the configuration, I ignore all properties except one, the Id field, same exception

I really don't understand why. Is there a way to know with more precision the problem ?

Update 1

failed MyTestMethod threw exception: AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types: MY_CLASS -> MyClass MyProject.DataContexts.MY_CLASS -> MyProject.BusinessModels.MyClass

Destination path: List`1[0]

1
both Id has same Type?user1968030
Can you post the full exception message?nemesv
@nemesv see update1, I tried to convert a single object and not a list, I get the same exceptionKris-I
Are you sure that Mapper.CreateMap<MY_CLASS, MyClass>(); gets called before the Mapper.Map? And also make sure that you have Mapper.CreateMap<MyProject.DataContexts.MY_CLASS, MyProject.BusinessModels.MyClass>(); maybe you have more types with the same name in different namespaces...nemesv
Yes CreateMap is called before Map and no other class with the same nameKris-I

1 Answers

3
votes

As there is no answer to this, I'd like to add that nemesv's comment to the question pointed me in the right direction. That being the CreateMapper statements weren't executed, resulting in the same exception as OP's.