title: Using Automapper static API in the latest release?
body: <p>I've upgraded <code>Automapper</code> from 4.2.1 to 5.0.0. I'm using the static API in a WebApi2 project and I'm trying to get the mapping to work, so I tried following <a href="https://stackoverflow.com/questions/36398318/automapper-mapper-createmaptsource-tdestination-is-obsolete">this SO answer</a>.</p>
  
  <p>So I changed the code to the following:</p>
  
  <pre><code>public static class AutoMapping
  {
      public static void Config()
      {
          Mapper.Initialize(main =&gt;
          {
              var config = new MapperConfiguration(cfg =&gt;
              {
                  cfg.CreateMissingTypeMaps = true;
                  cfg.CreateMap&lt;MyModel, MyDto&gt;().ReverseMap();
              });
              config.AssertConfigurationIsValid();
          });
      }
  }
  </code></pre>
  
  <p>The above is called from <code>Global.asax</code>.</p>
  
  <p>However, I get exception: </p>
  
  <blockquote>
    <p>Mapper not initialized. Call Initialize with appropriate configuration.</p>
  </blockquote>
  
  <p>What is the correct way to initialize <code>Automapper</code>, and do I need to change all my controllers now for mapping?</p>
  
  <p><strong>EDIT1</strong></p>
  
  <p>Firstly, the code above must be:</p>
  
  <pre><code>Mapper.Initialize(cfg =&gt; 
  {
      cfg.CreateMissingTypeMaps = true;
      cfg.CreateMap&lt;MyModel, MyDto&gt;().ReverseMap();
  });
  Mapper.Configuration.AssertConfigurationIsValid();
  </code></pre>
  
  <p>Secondly, the problem might be in the following method which I use to ignore missing properties:</p>
  
  <pre><code>public static IMappingExpression&lt;TSource, TDestination&gt; IgnoreUnmapped&lt;TSource, TDestination&gt;(this IMappingExpression&lt;TSource, TDestination&gt; expression)
  {
      var typeMap = Mapper.Configuration.FindTypeMapFor&lt;TSource, TDestination&gt;();
      if (typeMap != null)
      {
          foreach (var unmappedPropertyName in typeMap.GetUnmappedPropertyNames())
          {
              expression.ForMember(unmappedPropertyName, opt =&gt; opt.Ignore());
          }
      }
  
      return expression;
  }
  </code></pre>
  
  <p>I'm assuming 'Mapper.Configuration' is not yet configured because the above method is called within <code>Initialize</code> which configures the mapping.</p>
  
  <p>Is there an existing method within Automapper itself which I can use instead of the above?</p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>Would the following syntax work?</p>
  
  <pre><code>cfg.CreateMap&lt;MyModel, MyDto&gt;().ReverseMap().ForAllMembers(opt =&gt; opt.Ignore());
  </code></pre>