title: Configuring AutoMapper v4.2 on application start without the Static API
body: <p>I am attempting to migrate from the old static AutoMapper API to the new way of doing things as per <a href="https://lostechies.com/jimmybogard/2016/01/21/removing-the-static-api-from-automapper/" rel="noreferrer">this resource</a>.</p>
  
  <p>However, I am a bit confused as to how I should be configuring AutoMapper in a file like Startup.cs/Global.asax.</p>
  
  <p>The old way to do something like this was:</p>
  
  <pre><code>Mapper.Initialize(cfg =&gt; {
    cfg.CreateMap&lt;Source, Dest&gt;();
  });
  </code></pre>
  
  <p>Then anywhere throughout the code I could simply just do:</p>
  
  <pre><code>var dest = Mapper.Map&lt;Source, Dest&gt;(source);
  </code></pre>
  
  <p>Now with the new version it seems that there is no way to initialize AutoMapper on Application Start and then use it in the Controller. The only way I have figured out how to do it is doing everything in the controller like so:</p>
  
  <pre><code>var config = new MapperConfiguration(cfg =&gt; {
    cfg.CreateMap&lt;Source, Dest&gt;();
  });
  
  IMapper mapper = config.CreateMapper();
  var source = new Source();
  var dest = mapper.Map&lt;Source, Dest&gt;(source);
  </code></pre>
  
  <p>Do I really have to configure AutoMapper every single time I use it now in my MVC controllers or anywhere else in my application? Yes, the documentation shows you how to configure it the new way, but they are just setting it to a variable called config which can't work around my entire app.</p>
  
  <p>I found <a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="noreferrer">this documentation</a> on keeping the static feel. But I am a bit confused as to what MyApplication.Mapper is and where I should declare it. It seems like a global application property.</p>