I downloaded automapper to a separate class library. I want to use this automapper in web api. I want to add automapper to services in program.cs, but it gives the following error.
Severity Code Description Project File Line Hide Status Error CS1061 'IServiceCollection' does not contain a definition of 'AddAutoMapper' and no accessible extension method 'AddAutoMapper' was found that accepts a first argument of type 'IServiceCollection' (could be missing a using directive or assembly reference?) WebApi C:\Users\batu_\ Desktop\TaskProject\Backend\WebApi\Program.cs 8 Enabled
I downloaded automapper from nuget to map class library
Can't find AddAutoMapper in program.cs
builder.Services.AddAutoMapper(typeof(MappingProfile));
CodePudding user response:
You need to add a reference to: AutoMapper.Extensions.Microsoft.DependencyInjection