Open Closed

AutoMapperMappingException: Missing type map configuration or unsupported mapping. #814


User avatar
0
Gary created
  • ABP Framework version: 4.1.1
  • UI type: MVC
  • DB provider: EF Core
  • **Tiered (MVC)
  • Exception message and stack trace:AutoMapperMappingException: Missing type map configuration or unsupported mapping.
  • Steps to reproduce the issue: On create I want to move the data in the Prospectus table to the Student table. The Prospectus table is a subset of the Student table.

In the MapperProfile I created the map `//map the prospectus to the student

        CreateMap<ProspectusCreateDto, Student>().IgnoreFullAuditedObjectProperties().Ignore(x =>      x.ExtraProperties).Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id).Ignore(x => x.TenantId);`
        
        

In my ProspectusAppService class I modified the Create method

      public virtual async Task<ProspectusDto> CreateAsync(ProspectusCreateDto input)
        {
            var prospectus = ObjectMapper.Map<ProspectusCreateDto, Prospectus>(input);
            prospectus.TenantId = CurrentTenant.Id;

            //get the Position role from the position Id
            var SelectedPosition = _positionRepository.AsQueryable()
                    .Where(p => p.Id == prospectus.PositionId)
                    .Select(p => new { Role = p.Role, Id = p.Id }).FirstOrDefault();

            if (SelectedPosition.Role == "Student") //student
            {
                var student = ObjectMapper.Map<ProspectusCreateDto, Student>(input);
                student.TenantId = CurrentTenant.Id;

                //save it to the student table
                await _studentRepository.InsertAsync(student, autoSave: true);

                //delete it from the prospectus table if it exists
                if (prospectus.Id != default(Guid))
                {
                    await DeleteAsync(prospectus.Id);
                }

            }
            else
            {
                prospectus = await _prospectusRepository.InsertAsync(prospectus, autoSave: true);
            }
            return ObjectMapper.Map<Prospectus, ProspectusDto>(prospectus);
        }

At var student = ObjectMapper.Map<ProspectusCreateDto, Student>(input);

I get

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share the full code of ProspectusCreateDto and Student class?

    Have you tried the Automapper without abp?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Gary created

    Thankyou, for your help. I have found out the error, your post gave me the idea, a field in the Prospectus was a different type to the one in Students :-)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.