Add AutoMapper

We need to go to the Nuget Manager and install the following dependencies:

After these two dependencies are installed we need to create a folder called Helper, in this folder, we will create a class called AutoMapperProfiles.cs where we are going to contain all the mappings.

Once we have inherited Profile in our class we will create a constructor and it should look like this:

using AutoMapper;

namespace api_seed.Helpers
{
    public class AutoMapperProfiles : Profile
    {
        public AutoMapperProfiles()
        {

        }
    }
}

Our next step is to add AutoMapper in our ConfigureServices class.

// Add Automapper
services.AddAutoMapper(typeof(Startup));

Last updated