title: Automapper exception: "Missing type map configuration or unsupported mapping."
body: <p>I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa.
  Unfortunately I get an error message that states that the type map configuration is missing.</p>
  
  <p>I created a Ninject dependency resolver:</p>
  
  <pre><code>namespace MyNamespace.Infrastructure
  {
      public class NinjectDependencyResolver: IDependencyResolver
      {
          private IKernel kernel;
  
          public NinjectDependencyResolver(IKernel kernelParam)
          {
              kernel = kernelParam;
              AddBindings();
          }
  
          public object GetService(Type serviceType)
          {
              return kernel.TryGet(serviceType);
          }
  
          public IEnumerable&lt;object&gt; GetServices(Type serviceType)
          {
              return kernel.GetAll(serviceType);
          }
  
          private void AddBindings()
          {
              kernel.Bind&lt;IMyBLL&gt;().To&lt;MyBLL&gt;();
          }
      }
  }
  </code></pre>
  
  <p>I use this to create a controller:</p>
  
  <pre><code>namespace MyNamespace.Controllers
  {
      [Authorize]
      public class HomeController : Controller
      {
          private IMyBLL _myBLL;
  
          public HomeController(IMyBLL myBLLParam)
          {
              _myBLL = myBLLParam;
          }
  
          public PartialViewResult AddRecord()
          {
              return PartialView(new AddRecordViewModel());
          }
  
          [HttpPost]
          public void AddRecord(AddRecordViewModel recordViewModel)
          {
              var record = Mapper.Map&lt;Record&gt;(recordViewModel);
  
              _myBLL.AddRecord(record, User.Identity.Name);
          }
      }
  }
  </code></pre>
  
  <p>Global.asax:</p>
  
  <pre><code>namespace MyNamespace.WebApplication
  {
      public class MvcApplication : System.Web.HttpApplication
      {
          protected void Application_Start()
          {
              ApplicationUserManager.StartupAsync();
              AreaRegistration.RegisterAllAreas();
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
              AutoMapperWebConfiguration.Configure();
          }
      }
  }
  </code></pre>
  
  <p>This calls the AutoMapper configuration:</p>
  
  <pre><code>namespace MyNamespace.WebApplication.Infrastructure
  {
      public static class AutoMapperWebConfiguration
      {
          public static void Configure()
          {
              Mapper.Initialize(cfg =&gt; cfg.AddProfile(new RecordProfile()));
          }
      }
  
      public class RecordProfile : Profile
      {
          protected override void Configure()
          {
              Mapper.CreateMap&lt;AddRecordViewModel, Record&gt;().ReverseMap();
          }
      }
  }
  </code></pre>
  
  <p>When I run this I get the following error message:</p>
  
  <pre><code>Missing type map configuration or unsupported mapping.
  
  Mapping types:
  AddRecordViewModel -&gt; Record
   MyNamespace.WebApplication.ViewModels.Home.AddRecordViewModel -&gt; MyNamespace.Model.Record
  
   Destination path:
   Record
  
   Source value:
   MyNamespace.WebApplication.ViewModels.Home.AddRecordViewModel
  </code></pre>
  
  <p>Do I miss something.
  It worked fine before I used the Ninject dependency resolver.
  Now it does not seem to find the mappings.</p>
  
  <hr>
  
  <h2>Edit:</h2>
  
  <p>If I add the Mapping Creation directly to the controller method it works:</p>
  
  <pre><code>[HttpPost]
  public void AddRecord(AddRecordViewModel recordViewModel)
  {
      Mapper.CreateMap&lt;AddRecordViewModel, Record&gt;().ReverseMap();
      var record = Mapper.Map&lt;Record&gt;(recordViewModel);
  
      _myBLL.AddRecord(record, User.Identity.Name);
  }
  </code></pre>
  
  <p>The mapping itself and the models and view models do not seem to be the problem. I guess that the programm somehow does not find the mappings.</p>
  
  <p>Even if I call the Auto Mapper Web Configuration in the controller method it works: </p>
  
  <pre><code>public void AddRecord(AddRecordViewModel recordViewModel)
  {
      Infrastructure.AutoMapperWebConfiguration.Configure();
  
      var record = Mapper.Map&lt;Record&gt;(recordViewModel);
  
      _myBLL.AddRecord(record, User.Identity.Name);
  }
  </code></pre>