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.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11