Open Closed

How to do the mapping from EntityDto to EntityCreateDto #5495


User avatar
0
hanntd created

Hi, I'm trying to map from CountryDto to CountryCreateDto but it threw the error: AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping. Although I already add Createmap for above mapping:

public SharedInformationApplicationAutoMapperProfile()
{
    /* You can configure your AutoMapper mapping configuration here.
     * Alternatively, you can split your mapping configurations
     * into multiple profile classes for a better organization. */

    CreateMap<Country, CountryDto>();
    CreateMap<Country, CountryExcelDto>();
 **   CreateMap<CountryDto, CountryCreateDto>()
        .ReverseMap();
    CreateMap<CountryDto, CountryUpdateDto>()
        .ReverseMap();**

I call the mapping here and threw the error: if (editModel != null && e.IsNew) { await CountriesAppService.CreateAsync(ObjectMapper.Map<CountryDto, CountryCreateDto>(editModel)); }


2 Answer(s)
  • User Avatar
    0
    nlachmuthDev created

    Hi,

    in what project is the exception thrown? You might need to add the mapping inside the UI Layer´s AutoMapperProfile.

    Please let me know what UI Layer you use and if your application is tiered (seperated auth server)

  • User Avatar
    0
    hanntd created

    Thanks, I forgot to add the mapping for the UI Layer, now it already worked.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 25, 2025, 11:10