Home > Software design >  ASP.NET Core 6.0: Unable to resolve service for type 'AutoMapper.IMapper'
ASP.NET Core 6.0: Unable to resolve service for type 'AutoMapper.IMapper'

Time:12-01

(https://i.stack.imgur.com/J4v7h.png) I have installed both AutoMapper and AutoMapper.Extensions.Microsoft.DependencyInjection

But still I am getting the same error

CodePudding user response:

I didn't add the builder.services line in program.cs file that is

builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

CodePudding user response:

Have you added it in Program.cs like

builder.Services.AddAutoMapper(config =>
{
    config.AddProfile(typeof(YourMappingProfile));
});
  • Related