Trying to add AutoMapper to .NetCore1.1 - not recognising services.AddAutoMapper()

magna_nz picture magna_nz · Mar 21, 2017 · Viewed 12.6k times · Source

I've installed the following Nuget packages into my project:

  • Automapper
  • AutoMapper.Extensions.Microsoft.DependencyInjection

I have added the line to ConfigureServices in Startup.cs.

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddMvc();
    // . . .
    services.AddAutoMapper();
}

I'm still getting a red line under services.AddAutoMapper(). It says:

The Call is ambiguous between the following methods or properties: ServiceCollectionExtensions.AddAutoMapper(IServiceCollection, params Assembly[]) and ServiceCollectionExtensions.AddAutoMapper(IServiceCollection, params Type[])

Why is this happening? All the .NET Core add automapper guides I've read show to do it this way.

Answer

Ikram Shah picture Ikram Shah · Mar 8, 2018

I just ran into this problem and came to know that You need to include following Nuget package AutoMapper.Extensions.Microsoft.Dependencyinjection