2

We are using AutoMapper Profiles in order to keep our mappings decentralized. This works well, but we sometimes get some hard to debug issues when there are duplicate CreateMap calls. Is there a way to prevent this? This seems like it should be supported natively by the framework in an effort to cut down on difficult to find bugs.

I ran across this post describing what I'm looking for, but I don't think it was ever implemented.

randomsolutions
  • 2,075
  • 1
  • 19
  • 22
  • 1
    If you are looking for a way to avoid duplicate calls, then the answer here could help out. http://stackoverflow.com/a/6702539/2268417. There is a snippet of how you could verify if a mapping already exists. – quirkystack Apr 27 '17 at 20:00
  • @quirkystack That's not actually accurate, as Mapper.FindTypeMapFor has been removed in automapper-6. – Ashley Lee Jun 23 '17 at 14:18

1 Answers1

1

I ended up just inheriting from Profile and creating new "CreateMap" methods that just checked a static dictionary to see if the types had already been mapped. I'm sure there are other ways, but this suited my needs.

randomsolutions
  • 2,075
  • 1
  • 19
  • 22