Open Closed

Module Template Automapper problem #3599


User avatar
0
manuel42 created
  • ABP Framework version: v.6.0.0 (v5.3.3 other packages)

  • UI type: MVC

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): no

  • Exception message and stack trace:

  • Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.Account.Web.Pages.Account.LoginModel -> Volo.Abp.Account.AccountAppService -> Volo.Abp.Account.Emailing.AccountEmailer -> Volo.Abp.UI.Navigation.Urls.AppUrlProvider -> Volo.Abp.TenantManagement.TenantStore -> Volo.Abp.ObjectMapping.DefaultObjectMapper1[[Volo.Abp.TenantManagement.AbpTenantManagementDomainModule, Volo.Abp.TenantManagement.Domain, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Volo.Abp.AutoMapper.AutoMapperAutoObjectMappingProvider1[[Volo.Abp.TenantManagement.AbpTenantManagementDomainModule, Volo.Abp.TenantManagement.Domain, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null]] -> λ:Volo.Abp.AutoMapper.IMapperAccessor -> λ:Volo.Abp.AutoMapper.MapperAccessor.
    ---> AutoMapper.AutoMapperConfigurationException:
    Unmapped members were found. Review the types and members below.
    Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
    For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
    ======================================================================================
    DatabaseBlob -> BlobDto (Destination member list)
    Volo.Abp.BlobStoring.Database.DatabaseBlob -> IT42Portal.AssetManagement.Blob.BlobDto (Destination member list)

Unmapped properties:
Category

  • Steps to reproduce the issue:"

Hi, I have downloaded a module template with abp suite. Then I have created a UnifiedEfCoreEntityExtensionMappings.cs in the xxx.Web.Unified Module. This Class contains the code for the extension

public static void Configure()
{
    OneTimeRunner.Run(() =>            
    {
              
                ObjectExtensionManager.Instance
                   .MapEfCoreProperty("AdditionalProperty");

              more extensions .....
     });
}
  

I call this method in the UnifieddbContextFactory.cs.

 public UnifiedDbContext CreateDbContext(string[] args)
 {
        UnifiedEfCoreEntityExtensionMappings.Configure(); // HERE

        var configuration = BuildConfiguration();

        var builder = new DbContextOptionsBuilder()
            .UseSqlServer(configuration.GetConnectionString("Default"));

        return new UnifiedDbContext(builder.Options);
 }

The migrations is created and the extensions are done in the database.
But when I create the mappings I always got the above mentioned exception.

May mappings are done in the xxx.Application.Module and looks like this


        CreateMap()
            .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true)
            .ReverseMap();
            
        ... more mappings they look identical

What should I do that the mapping works ?

thank you for your help


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

    hi manuel42

    I will check this.

  • User Avatar
    0
    manuel42 created

    Hi maliming,

    thank you for checking.
    In the meantime I have tried to use another template where all packages have the same version (5.3.4). I got the same error.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please share your project to liming.ma@volosoft.com

  • User Avatar
    0
    manuel42 created

    I have sent it to you.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi
    I didn't received it yet, Can you confirm that?

  • User Avatar
    0
    manuel42 created

    I have sent it as 7zip but it was blocked. How should I sent it to you ?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can create a GitHub private repository and invite me. https://github.com/maliming

  • User Avatar
    0
    manuel42 created

    Done you should received the inivite

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Yes, I will download and check.

    image.png

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

            CreateMap<DatabaseBlob, BlobDto>(MemberList.Destination)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
            CreateMap<BlobDto, DatabaseBlob>(MemberList.Source)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
    
            CreateMap<DatabaseBlob, CreateBlobDto>(MemberList.Destination)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
    
            CreateMap<CreateBlobDto, DatabaseBlob>(MemberList.Source)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
    
            CreateMap<DatabaseBlob, UpdateBlobDto>(MemberList.Destination)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
            CreateMap<UpdateBlobDto, DatabaseBlob>(MemberList.Source)
                .MapExtraProperties(MappingPropertyDefinitionChecks.None, null, true);
    
  • User Avatar
    0
    manuel42 created

    Hi same error again. I also have created the constructor.

    DatabaseBlob -> BlobDto (Destination member list)
    Volo.Abp.BlobStoring.Database.DatabaseBlob -> IT42Portal.AssetManagement.Blob.BlobDto (Destination member list)

    Unmapped properties:
    Category

    BlobDto -> DatabaseBlob (Source member list)
    IT42Portal.AssetManagement.Blob.BlobDto -> Volo.Abp.BlobStoring.Database.DatabaseBlob (Source member list)

    Unmapped properties:
    Category
    No available constructor.

    DatabaseBlob -> CreateBlobDto (Destination member list)
    Volo.Abp.BlobStoring.Database.DatabaseBlob -> IT42Portal.AssetManagement.Blob.CreateBlobDto (Destination member list)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    you can configure the properties by automapper documents

    https://docs.automapper.org/en/stable/Projection.html

  • User Avatar
    0
    manuel42 created

    How can I select the extensions properties from the DatabaseBlob in the mapper ?
    I always got a exception I tried to acces the properties like this

    .ForPath(dest => dest.ExtraProperties["Category"], opt => opt.MapFrom(src => src.Category))

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    OK, I will check again

  • User Avatar
    1
    manuel42 created

    Finally I found the solution

    .ForMember(dest => dest.ExtraProperties,
    opt => opt.MapFrom(r => new Dictionary<string, object>() { { "Category", r.Category }, .... and so on))

    Maybe this will help others.
    Thank you maliming for your help.

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