In this last part of the series I wanted to talk about how to register automapper at startup of your web application, in doing so it would help speed things up with automapper.

There are many ways to do it, the easiest way is to just have a method inside Global.asax.cs file in your Application_Start like below

And if you are using an IoC container, than one can use the Command Pattern for a StartupTask, below is an example of using ServiceLocator for startup.

Note: one will need to remove all the CreateMap code in their controller to here, you do not need to call CreateMap anymore since the startup task takes care of it.

This concludes our final segment on Automapper, hopefully you will find this helpful πŸ˜›

Previous Post:
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)
Part 4 (Projection)
Part 5 (CustomResolver)
Part 6 (CustomFormatter)