如何调试AutoMapper.AutoMapperMappingException

Mys*_*ter 8 automapper

当我得到这个异常时,有没有办法从automapper获取更多细节:

AutoMapper.AutoMapperMappingException
Run Code Online (Sandbox Code Playgroud)

通常它会告诉我2种类型的映射,但不会告诉我哪个解析器或部分映射失败.

Mys*_*ter 16

简单的回答,就是调用这种方法,最好是在你的单元测试中.

// ensure your configuration mappings are loaded first (bootstrapper)
Mapper.AssertConfigurationIsValid();
Run Code Online (Sandbox Code Playgroud)

请参阅:http://docs.automapper.org/en/stable/Getting-started.html#how-do-i-test-my-mappings