Hi Abp Team,
I have an issue with AutoMapperProfile. I am using AutoMapper after update to version 10.0.1 i am getting an issue with it. It tells me to use Mapperly. In application layer it works but in Blazor it asks to use mapperly.
How can I resolve this issue?
6 Answer(s)
-
0
- Solution
What changed in v10.0.1
- ABP Framework modules switched their default object mapper from AutoMapper to Mapperly in v10. You can still use AutoMapper in your own application layers, but new ABP templates and modules favor Mapperly. This is why you see guidance “use Mapperly,” especially in UI layers like Blazor.
Why it “works in Application layer but not in Blazor”
- Your Application layer likely still references and configures Volo.Abp.AutoMapper and your AutoMapper profiles. However, your Blazor project was created/updated to v10 where the UI integration uses Mapperly by default. If the Blazor project no longer references Volo.Abp.AutoMapper or doesn’t register your AutoMapper profiles, AutoMapper-based mappings won’t be available there.
Two supported ways to resolve
Option A — Keep using AutoMapper everywhere (quickest to keep existing profiles)
- Add the AutoMapper integration in all layers that need it (including Blazor):
- Add package references to the Blazor project:
- Volo.Abp.AutoMapper
- AutoMapper
- AutoMapper.Extensions.Microsoft.DependencyInjection
- Add package references to the Blazor project:
- Ensure your Blazor module depends on AbpAutoMapperModule and registers your profiles:
- Add the AutoMapper integration in all layers that need it (including Blazor):
using Volo.Abp; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; [DependsOn( typeof(AbpAutoMapperModule) )] public class MyProjectBlazorModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper<MyProjectBlazorModule>(); Configure<AbpAutoMapperOptions>(options => { // Add your AutoMapper profiles that contain CreateMap<,>() definitions options.AddMaps<MyProjectApplicationModule>(validate: true); options.AddMaps<MyProjectBlazorModule>(validate: true); }); } }- Make sure your AutoMapper Profile classes are in assemblies scanned above (e.g., Application and Blazor projects if you keep profiles there).
- If you previously removed Volo.Abp.AutoMapper due to the upgrade, restore it in the .csproj and module DependsOn.
Option B — Migrate to Mapperly (recommended for ABP v10+)
- Replace AutoMapper integration with Mapperly across the solution:
- In all projects, replace Volo.Abp.AutoMapper with Volo.Abp.Mapperly (csproj).
- In code, replace:
- using Volo.Abp.AutoMapper; → using Volo.Abp.Mapperly;
- AbpAutoMapperModule → AbpMapperlyModule
- AddAutoMapperObjectMapper → AddMapperlyObjectMapper
- Remove Configure<AbpAutoMapperOptions> blocks.
- Convert your AutoMapper Profile mappings to Mapperly mappers using partial classes with [Mapper] and Map/ReverseMap methods. Example:
using Riok.Mapperly.Abstractions; using Volo.Abp.Mapperly; [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] public partial class MyEntityToDtoMapper : MapperBase<MyEntity, MyEntityDto> { public override partial MyEntityDto Map(MyEntity source); public override partial void Map(MyEntity source, MyEntityDto destination); }- Register Mapperly in each layer (including Blazor) that needs mappings:
using Volo.Abp; using Volo.Abp.Mapperly; using Volo.Abp.Modularity; [DependsOn(typeof(AbpMapperlyModule))] public class MyProjectBlazorModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddMapperlyObjectMapper<MyProjectBlazorModule>(); } }- Build to let source generators produce mapping implementations. Fix any missing attributes (e.g., MapProperty, MapperIgnoreTarget) and AfterMap custom logic.
- Practical recommendation
- If you need a fast fix to keep your existing profiles: follow Option A and re-enable AutoMapper in the Blazor project.
- If you can invest a bit of time for the future-proof path: follow Option B and migrate to Mapperly using the guide below.
- Sources
- ABP 10 migration and Mapperly adoption:
- https://abp.io/docs/10.0/release-info/migration-guides/abp-10-0
- https://abp.io/docs/10.0/release-info/migration-guides/AutoMapper-To-Mapperly
- Background and examples (community/ABP context):
- https://abp.io/community/articles/best-free-alternatives-to-automapper-in-net-l9f5ii8s
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
hi
Can you add code below to your Blazor project?
public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper(); }Thanks.
-
0
This code is there, but still i am getting error when Actions->Edit
blazor.web.js:1 [2025-12-20T05:02:32.742Z] Error: Volo.Abp.AbpException: No object mapping was found for the specified source and destination types. Mapping attempted: TaskGroupDto -> TaskGroupUpdateDto Payhas.TaskManagement.TaskGroups.TaskGroupDto -> Payhas.TaskManagement.TaskGroups.TaskGroupUpdateDto How to fix: Define a mapping class for these types: - Use MapperBase<TSource, TDestination> for one-way mapping. - Use TwoWayMapperBase<TDestination, TSource> for two-way mapping. For details, see the Mapperly integration document https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping#mapperly-integration at Volo.Abp.Mapperly.MapperlyAutoObjectMappingProvider.Map[TSource,TDestination](Object source) at Volo.Abp.ObjectMapping.DefaultObjectMapper.AutoMap[TSource,TDestination](Object source) at Volo.Abp.ObjectMapping.DefaultObjectMapper.Map[TSource,TDestination](TSource source) at Payhas.TaskManagement.Blazor.Pages.TaskManagement.TaskGroups.OpenEditTaskGroupModalAsync(TaskGroupDto input) in D:\Billing_Platform\modules\payhas.taskmanagement\src\Payhas.TaskManagement.Blazor\Pages\TaskManagement\TaskGroups.razor.cs:line 218 at Payhas.TaskManagement.Blazor.Pages.TaskManagement.TaskGroups.<>c__DisplayClass107_0.<<BuildRenderTree>b__41>d.MoveNext() in D:\Billing_Platform\modules\payhas.taskmanagement\src\Payhas.TaskManagement.Blazor\Pages\TaskManagement\TaskGroups.razor:line 151 --- End of stack trace from previous location --- at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Volo.Abp.BlazoriseUI.Components.EntityAction`1.ActionClickedAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Blazorise.DropdownItem.ClickHandler() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)this is the code :
public class TaskManagementBlazorModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper<TaskManagementBlazorModule>(); Configure<AbpAutoMapperOptions>(options => { options.AddProfile<TaskManagementBlazorAutoMapperProfile>(validate: true); }); Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new TaskManagementMenuContributor()); }); Configure<AbpRouterOptions>(options => { options.AdditionalAssemblies.Add(typeof(TaskManagementBlazorModule).Assembly); }); }public class TaskManagementBlazorAutoMapperProfile : Profile { public TaskManagementBlazorAutoMapperProfile() { /* You can configure your AutoMapper mapping configuration here. * Alternatively, you can split your mapping configurations * into multiple profile classes for a better organization. */ CreateMap<TaskGroupDto, TaskGroupUpdateDto>(); CreateMap<TaskTypeDto, TaskTypeUpdateDto>(); CreateMap<TaskItemDto, TaskItemUpdateDto>(); } }and here is application configuration :
public class TaskManagementApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper<TaskManagementApplicationModule>(); Configure<AbpAutoMapperOptions>(options => { options.AddMaps<TaskManagementApplicationModule>(validate: true); }); } } -
0
hi
If you specify the mapper context (
TaskManagementBlazorModule), you must specify it when using it.context.Services.AddAutoMapperObjectMapper<TaskManagementBlazorModule>();Check your base class and set the
ObjectMapperContext = typeof(TaskManagementBlazorModule);Thanks.
-
0
It solved the issue.
Thanks
-
0
Great 👍