title: Mapper already initialized
body: <p>I have a 3-layer architecture Web Api solution with 3 projects inside: data, business and presentation layers. I need to initialize two different mappers in two business and presentation layers.</p>
  
  <p>I've created a static class and method to initialize one mapper in business logic:</p>
  
  <pre><code>using AutoMapper;
  using Shop.BLL.DTOModels;
  using Shop.DAL.Models;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Shop.BLL.InitMapper
  {
      public static class InitializeMapperBLL
      {
          public static void RegisterMappings()
          {
              Mapper.Initialize(cfg =&gt; cfg.CreateMap&lt;Category, DTOCategoryModel&gt;());
          }
      }
  }
  </code></pre>
  
  <p>And call it like here:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Shop.DAL.Repositories;
  using AutoMapper;
  using Shop.BLL.DTOModels;
  using Shop.DAL.Models;
  using Shop.BLL.Interfaces;
  using Shop.DAL.Interfaces;
  using Shop.BLL.InitMapper;
  
  namespace Shop.BLL.Services
  {
      public class CategoryService : ICategoryService
      {
          IUnitOfWork Database { get; set; }
  
          public CategoryService(IUnitOfWork uow)
          {
              Database = uow;
          }
  
          public IEnumerable&lt;DTOCategoryModel&gt; GetCategories()
          {
  //I call it here
              InitializeMapperBLL.RegisterMappings();
  
              return Mapper.Map&lt;IEnumerable&lt;Category&gt;, List&lt;DTOCategoryModel&gt;&gt;(Database.Categories.GetAll());
          }
          public void Dispose()
          {
              Database.Dispose();
          }
  
  
      }
  }
  </code></pre>
  
  <p>And in the presentation layer I do the same thing:</p>
  
  <pre><code>using AutoMapper;
  using Shop.API.ViewModels;
  using Shop.BLL.DTOModels;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Shop.API.MapperInit
  {
      public static class InitializeMapperAPI
      {
          public static void RegisterMappings()
          {
              Mapper.Initialize(cfg =&gt; cfg.CreateMap&lt;DTOCategoryModel, CategoryViewModel&gt;());
          }
      }
  }
  </code></pre>
  
  <p>And call in Global.asax</p>
  
  <pre><code>protected void Application_Start()
          {
              AreaRegistration.RegisterAllAreas();
              GlobalConfiguration.Configure(WebApiConfig.Register);
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
        //here I call it
              InitializeMapperAPI.RegisterMappings();
  
              CreateKernel();
          }
  </code></pre>
  
  <p>And I've got the error Mapper already initialized. You must call Initialize once per application domain/process.</p>
  
  <p>How to solve this problem?</p>