title: Unable to register and add automapper profile in Autofac
body: <p>I have a multitenant web application which has multiple modules. I am using autofac as IOC and Automapper to map my model and entities. In the following code I am able to add UserAuthenticationMapper profile to the automapper, but unable to add CustomerDataMapper profile.
  Autofac is adding just one mapper profile to the automapper MappingEngine and ignoring rest of it.
  Whats wrong I am doing here?</p>
  
  <p>Here's my UserAuthentication Module:</p>
  
  <pre><code> public class UserAuthenticationModule: Autofac.Module
   {
      protected override void Load(ContainerBuilder builder)
      {
          builder.RegisterType&lt;MappingEngine&gt;().As&lt;IMappingEngine&gt;();
  
          builder.Register(ctx =&gt;
          {
              var configStore = new ConfigurationStore
             (new TypeMapFactory(),  MapperRegistry.AllMappers());
              configStore.AddProfile&lt;UserAuthenticationMapperProfile&gt;();
              return configStore;
          })
          .AsImplementedInterfaces()
          .SingleInstance();
  
          var assembly = Assembly.GetExecutingAssembly();
          builder.RegisterAssemblyTypes(assembly)
                 .Where(t =&gt; t.Name.EndsWith("Service"))
                 .AsImplementedInterfaces()
                 .SingleInstance();
        }
    }
  </code></pre>
  
  <p>CustomerData Modue:</p>
  
  <pre><code>  public class CustomerDataModule : Autofac.Module
    {
      protected override void Load(ContainerBuilder builder)
      {
          builder.RegisterType&lt;CustomerDataService&gt;()
              .As&lt;ICustomerDataService&gt;()
              .InstancePerDependency();
  
          builder.RegisterType&lt;MappingEngine&gt;().As&lt;IMappingEngine&gt;();
  
          builder.Register(ctx =&gt;
              {
                  var configStore = new ConfigurationStore
                  (new TypeMapFactory(), MapperRegistry.AllMappers());
                  configStore.AddProfile&lt;CustomerDataMapperProfile&gt;();
                  return configStore;
              })
                 .AsImplementedInterfaces()
                 .SingleInstance();
        }
     }
  </code></pre>
  
  <p>here is some additional code to show how i am loading these modules in Global.asax</p>
  
  <pre><code>    static IContainerProvider _containerProvider;
  
      public IContainerProvider ContainerProvider
      {
          get { return _containerProvider; }
      }
  
      void Application_Start(object sender, EventArgs e)
      {
          RouteTable.Routes.MapHttpRoute(
               name: "ActionApi",
               routeTemplate: "api/{controller}/{action}"
           );
  
          RouteTable.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = System.Web.Http.RouteParameter.Optional }
          );
        var builder = new ContainerBuilder();
        builder.RegisterModule&lt;UserAuthenticationModule&gt;();
        builder.RegisterModule&lt;CustomerDataModule&gt;();
        _containerProvider = new ContainerProvider(builder.Build());
       }
  </code></pre>
  
  <p>Error:</p>
  
  <p><strong>An exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll but was not handled in user code
  Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nUser -> UserModel</strong></p>