6

In my Startup.cs file I have an AutoMapper configuration in my ConfigureServices method:

AutoMapper.Mapper.Initialize(c => c.AddMaps(typeof(Models.MapperProfile), typeof(Data.Ef.MapperProfile)));
namespace Rm.Combo.Api.Models
{
    public class MapperProfile : Profile
    {
        public MapperProfile()
        {
            CreateMap<NewCashoutModel, App.Cashouts.InitiateCashoutCommand>();
        }
    }
}
namespace Rm.Combo.Data.Ef
{
    public class MapperProfile : Profile
    {
        public MapperProfile()
        {
            CreateMap<Domain.Cashouts.Cashout, Data.Cashouts.CashoutModel>();
        }
    }
}

Seems there was a certain number of breaking changes since I am moving from version 8.1.1 to the 9.0.0.

I tried to check those particular links:

But none of them says how to

Natalie Perret
  • 8,013
  • 12
  • 66
  • 129

1 Answers1

8

Starting with 9.0, the static API is no longer available.

You could use AutoMapper via Dependency Injection like below:

1.Install AutoMapper.Extensions.Microsoft.DependencyInjection

2.Register a service in ConfigureServices on Startup.cs:

services.AddAutoMapper(typeof(MapperProfile));

Reference: How to using AutoMapper on ASP.NET Core via Dependency Injection

Rena
  • 30,832
  • 6
  • 37
  • 72