title: Auto Mapper 5, no Ioc and Webforms
body: <p>Now that AutoMapper is abolishing both the static API and the ability to change the mappings at runtime I have a problem with my WebForms application without an IoC manager.</p>
  
  <p>For the sake of this question <strong>take as given</strong> I cannot introduce an IoC manager into this application, and while it would be "good to do" the application has been working fine without it for a number of years, and it cannot be done right at the moment. In the future maybe, but not now.</p>
  
  <p>With AutoMapper what I used to do before was have a method in each class I instantiated that was called automatically by the constructor. In that method I would have the necessary:</p>
  
  <pre><code>Mapper.CreateMap&lt;&gt;()
  </code></pre>
  
  <p>calls. This has the following advantages:</p>
  
  <ul>
  <li>I only mapped what I needed per request (and depending on program flow this list of mappings would grow to what I needed)</li>
  <li>All types were "local" - meaning I did not have to reference other projects in the solution</li>
  </ul>
  
  <p>I was happy to live with the performance hit each request of doing things this way instead of doing this once in Application_Start().</p>
  
  <p>However with AutoMapper 5... Having read <a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="nofollow">migrating from the static API</a> it appears that I now have to:</p>
  
  <ol>
  <li>Do all the mappings "somewhere" where I have access to <strong>all the types I want to map</strong>. So no matter where I put this I have to reference every other assembly in my solution?</li>
  <li>Having stored the MapperConfiguration() instance somewhere globally accessible - lets say either HttpContext or HttpApplication so I can call MapperConfiguration.CreateMapper() I now need to make sure that I have access to 
  HttpContext / HttpApplication <strong>everywhere</strong>. This ultimately means projects that have no need of say the HttpContext will now need to access it.</li>
  </ol>
  
  <p>If my assumptions in 1. &amp; 2. above are correct I now have a big mess of tightly coupled spaghetti code.</p>
  
  <p>So my question is this:</p>
  
  <p>How do I use AutoMapper 5 in a webforms application with numerous projects (and hence many types) in the solution, without an IoC elegantly?</p>