Configuring AutoMapper 4.2 with built in IoC in ASP.NET Core 1.0 MVC6
<p>I am trying to figure out the proper way to configure AutoMapper in my application's Startup.cs file and then use it throughout my application.</p>

<p>I am trying to use <a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="noreferrer">this documentation</a> which somewhat explains how to still give AutoMapper a static feel without the old static API. The example uses StructureMap.</p>

<p>I would like to know how I can do something similar, but in a Core 1.0 app using the built in services container.</p>

<p>I am assuming that in the Configure function I would configure AutoMapper and then in the ConfigureServices function I would add it as a transient.</p>

<p>I am assuming in the end the cleanest and most proper way to do this is using dependency injection. Here is my current attempt but it is not working:</p>

<p><strong>Startup.cs</strong></p>

<pre><code>public IMapper Mapper { get; set; }
private MapperConfiguration MapperConfiguration { get; set; }
public void ConfigureServices(IServiceCollection services)
{
     services.AddTransient&lt;IMapper, Mapper&gt;();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    MapperConfiguration MapperConfiguration = new MapperConfiguration(cfg =&gt;
    {
        cfg.CreateMap&lt;Product, ProductViewModel&gt;().ReverseMap();
    });

    Mapper = MapperConfiguration.CreateMapper();
}
</code></pre>

<p><strong>In my controller:</strong></p>

<pre><code>private IMapper _mapper { get; set; }
// Constructor
public ProductsController(IMapper mapper)
{
    _mapper = mapper;
}

public IActionResult Create(ProductViewModel vm)
{
    Product product = _mapper.Map&lt;ProductViewModel, Product&gt;(vm);
}
</code></pre>

<p>It just isn't working at all... I must be missing some step or doing something wrong.</p>