I am new to Automapper.
I have added Nuget package - Automapper into my Manager (BLL) and DAL layer.
Now, below is related stuff:
Below is the statment of Manager library that giving me exception:
this.dataRepository.Update(Mapper.Map<StudentMaster>(studentDTO));
Exception is as follow:
Missing type map configuration or unsupported mapping.
Mapping types:
studentDTO -> StudentMaster
Admin.App.DTO.studentDTO-> Admin.App.DAL.StudentMaster
In case of select/where query on EF, it is working and able to map using
.Project().To<TReturn>()
I wrote an Autoconfiguration.cs file as follows:
public static class AutoMapperConfiguration
{
    public static void Configure()
    {
        ConfigureStudentMasterMaps();
    }
    private static void ConfigureStudentMasterMaps()
    {
        Mapper.CreateMap<StudentMaster, studentDTO>();                  
    }
}
Note:
Both the entity - StudentMaster (model) entity and StudentDTO have the same properties.
Please guide me how I could resolve this issue.
Thank You
See Getting-started https://github.com/AutoMapper/AutoMapper/wiki/Getting-started
CreateMap<**TSource, TDestination**>()
You must add
Mapper.CreateMap<studentDTO, StudentMaster>();
After mapping configuration call
Mapper.AssertConfigurationIsValid();
                        I had a similar problem, I forgot to register in the Global.asax
public class WebApiApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        GlobalConfiguration.Configure(WebApiConfig.Register);
        AutoMapperConfig.RegisterMappings();
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With