automapperautomapper-6

Does Automapper allow disabling the (auto-)flattening?


According to documentation Automapper performs an automatic mapping besides the "normal" (property to property within mapable types).

However this functionality caused some unintentional behavior when dealing with some DTO within Entity Framework sometimes triggering data loads through navigation properties and I thought about disabling it altogether (i.e. at MapperConfiguration level).

I know that changing some names or using [NotMapped] might do the trick, but this requires paying attention to each case.

Question: Does Automapper allow disabling the (auto-)flattening?


Solution

  • No, but you can write a naming convention that doesn't do anything. See this PR for an example.