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

I'm running into the same issue, so checked the sourcecode and tests for guidance. It seems you need to pass either an assembly or a "marker type" inside the assembly you want scanned. I went for the following as my Profile classes are in the same assembly as the Startup class.

services.AddAutoMapper(typeof(Startup));

Not sure why this is happening, it could very well be something to do with .NET Core 1.1 but I have found a workaround.

Instead of doing services.AddAutoMapper() in ConfigureServices, replace it with the below.

var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            var mapper = config.CreateMapper();
            services.AddSingleton(mapper);

Where MappingProfile() is the class in which you have your CreateMap.


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