Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

override void Configure() in Automapper Profile giving compile error "AutoMapperBootstrap.Configure()': no suitable method found to override"

public class AutoMapperBootstrap : AutoMapper.Profile
{
    protected override void Configure()
    {
        //ReplaceMemberName("Z", "A");
        //CreateMap<Source, Destination>(); 
    }
    public override string ProfileName
    {
        get { return this.GetType().Name; }
    }
}

I have this AutoMapperBootstrap class in the App_Start folder of my MVC Application.

In "configure" method it is giving compiler error- "No Suitable method to override", I am getting the error for configure method and not for ProfileName

I have seen many examples in the StackOverflow overriding configure method of the profile in custom Automapper profile.

But why I am getting this compiler error.

Please let me know what is the mistake I am making??

or is it the latest version of Automapper does not have this Configure method to be overridden.

Note: I have downloaded latest Automapper version 6.1.1.0 from Nuget into my application.

like image 341
Ritesh Rajak Avatar asked Sep 21 '17 07:09

Ritesh Rajak


1 Answers

Newer versions of AutoMapper have a different method for setting up a profile. I am using the method described here to set up automating in a class library in a .net project.

namespace Project.Helpers
{
    public class NewMapperProfile : Profile
    {
        public NewMapperProfile()
        {
            CreateMap<ClassA, ClassB>();
        }
    }
}
like image 107
Mathew Casper Avatar answered Jan 03 '23 19:01

Mathew Casper