title: Add inner mapper to AutoMapper mapping profile
body: <p>I'm trying to map an object of type source to destination and it has some inner mappings needed. I've created a custom mapper like this.</p>
  <pre><code>public class CustomerMappingProfile : ITypeConverter&lt;Customer, CustomerDTO&gt;
      {
          public CustomerDTO Convert(Customer input, CustomerDTO destination, ResolutionContext context)
          {
              var CustomerDTO = new ObjectMapper&lt;CustomerDTO, Customer&gt;().Apply(input);
              CustomerDTO.NumbOfSeniorYears = input.YearsList != null ? input.YearsList.Count(p =&gt; p.Seniority == SeniorityEnum.Senior) : 0;
              CustomerDTO.NumOfYears = input.NumOfYears.Count();
              CustomerDTO.SearchTypeSelection = input.SearchTypeSelection;
              CustomerDTO.UpgradeTypes = input.UpgradeTypes;
              if (input.Rewards.Any())
              {
                  foreach (var reward in input.Rewards)
                  {
                      var result = Mapper.Map&lt;Customer.Rewards, RewardsDTO&gt;(reward);
                      CustomerDTO.Rewards.Add(result);
                  }
              }
              if (input.EliteLevel == -1)
              {
                  CustomerDTO.EliteLevel = null;
              }
              else
              {
                  CustomerDTO.EliteLevel = input.EliteLevel;
              }
              var softLoggedIn = Helper.Util.PersServicesUtil.GetCharacteristic(input.Characteristics, &quot;SOFT_LOGGED_IN&quot;);
              if (softLoggedIn != null)
              {
                  if (softLoggedIn.Equals(&quot;true&quot;))
                  {
                      CustomerDTO.SoftLoginIndicator = true;
                  }
                  else
                  {
                      CustomerDTO.SoftLoginIndicator = false;
                  }
              }
              CustomerDTO.SessionId = Customer.SessionId.ToLower();
              return CustomerDTO;
          }
  
  
      }
  </code></pre>
  <p>And I created Mapping profile</p>
  <pre><code>  public class MappingProfile : Profile
      {
          public MappingProfile()
          {
              CreateMap&lt;Rewards, RewardsDTO&gt;();
              CreateMap&lt;Customer, CustomerDTO&gt;().ConvertUsing(new CustomerMappingProfile());;
          }
      }
  </code></pre>
  <p>And Injected the mapping profile into startup.cs</p>
  <pre><code>var config = new MapperConfiguration(cfg =&gt;
              {
                  cfg.AddProfile(new MappingProfile());
              });
  
              services.AddSingleton(sp =&gt; config.CreateMapper());
  </code></pre>
  <p>But I'm getting exception <code>InvalidOperationException: Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.</code>  at Inner mapping with in the custom mapper at line <code>Mapper.Map&lt;Customer.Rewards, RewardsDTO&gt;(reward);</code></p>
  <p>Any idea on how to add inner mapping?</p>