AutoMapper Tutorial

Pitfalls

If you're using the static Mapper method, configuration should only happen once per AppDomain. That means the best place to put the configuration code is in application startup, such as the Global.asax file for ASP.NET applications. Typically, the configuration bootstrapper class is in its own class, and this bootstrapper class is called from the startup method.

('Configuration code' - I mean call 'Mapper.CreateMap'.)

For example, if you will call

Mapper.CreateMap<>();		
Mapper.Map<>();

in two actions and in each action there will be call of CreateMap where you will specify to ignore different properties, than last created config will work.

Page 6 of 7