4

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]

5
  • both Id has same Type? Commented Feb 28, 2013 at 8:01
  • Can you post the full exception message? Commented Feb 28, 2013 at 9:05
  • @nemesv see update1, I tried to convert a single object and not a list, I get the same exception Commented Feb 28, 2013 at 9:19
  • 3
    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... Commented Feb 28, 2013 at 9:21
  • Yes CreateMap is called before Map and no other class with the same name Commented Feb 28, 2013 at 9:41

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.