Maps entities to DTOs in ABP apps via IObjectMapper, AutoMapper profiles, or Mapperly mappers. Covers registration, extra properties, collections, and mapping-direction rules.
Ships in abp-module-development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP abstracts object mapping behind IObjectMapper (in the Volo.Abp.ObjectMapping package) and provides integrations for AutoMapper and Mapperly. Application code depends only on the abstraction; you pick the provider per module.
IObjectMapper.MapToEntityAsync overrides) — use build-crud-application-services. This skill is only the mapping mechanics..MapExtraProperties() / [MapExtraProperties] only covers mapping already-defined extra properties.IObjectMapper defines two Map overloads. ApplicationService exposes an ObjectMapper property; elsewhere inject IObjectMapper directly.
// Create a new destination DTO from an entity
var userDto = ObjectMapper.Map<User, UserDto>(user);
// Map onto an existing destination object
ObjectMapper.Map<User, UserDto>(user, userDto);
The first generic argument is the source type, the second the destination type. You must define the mappings first (see below).
ABP's DDD guidance is about where auto-mapping is safe:
CrudAppService maps input onto the entity this way by default. For a rich domain entity (parameterized constructor, non-public setters, business rules), don't auto-map onto it — build and mutate it explicitly through its constructor and methods (or a domain service), or override CrudAppService's MapToEntityAsync (see build-crud-application-services). Auto-mapping onto a rich entity fights the domain model:
// Output: map the entity to a DTO
return ObjectMapper.Map<Issue, IssueDto>(issue);
// Input to a rich entity: build it explicitly — NOT ObjectMapper.Map<CreateIssueDto, Issue>(input)
var issue = new Issue(GuidGenerator.Create(), input.RepositoryId, input.Title, input.Text);
IValidatableObject), never domain validation — e.g. don't check a unique-name rule in the DTO (that's domain logic — see handle-validation-and-errors and separate-domain-and-application-logic).Add the Volo.Abp.AutoMapper package and depend on AbpAutoMapperModule.
public class MyProfile : Profile
{
public MyProfile()
{
CreateMap<User, UserDto>();
}
}
AddMaps<TModule>() registers all profiles (and attribute mappings) in the assembly of the given class — typically your module class:
[DependsOn(typeof(AbpAutoMapperModule))]
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyModule>(validate: true);
});
}
}
validate (default false) enables AutoMapper configuration validation; enabling it is a recommended best practice.AddMaps<MyModule>() without validation, then options.AddProfile<MyProfile>(validate: true) per profile.CreateMap<User, UserDto>().MapExtraProperties(); // map extra properties (both must implement IHasExtraProperties)
CreateMap<ProductDto, Product>().IgnoreAuditedObjectProperties(); // also IgnoreFullAuditedObjectProperties(), IgnoreCreationAuditedObjectProperties()
CreateMap<SimpleClass1, SimpleClass2>().Ignore(x => x.CreationTime); // shorthand for ForMember(..., map => map.Ignore())
Add the Volo.Abp.Mapperly package and depend on AbpMapperlyModule. Mapperly is a source generator, so mapper classes and methods must be partial.
[Mapper]
public partial class UserToUserDtoMapper : MapperBase<User, UserDto>
{
public override partial UserDto Map(User source);
public override partial void Map(User source, UserDto destination);
}
TwoWayMapperBase<User, UserDto> to also generate ReverseMap.BeforeMap / AfterMap (and reverse variants) for pre/post logic.[MapExtraProperties] attribute on the mapper class to map extra properties (both types must implement IHasExtraProperties).protected set / private set are fine when Mapperly's member visibility is configured to reach them), a constructor parameter, or an explicit mapping. Destination properties with no writable path are ignored.NullReferenceException at runtime.IAbpMapperlyMapper<,> interfaces on one class, or map nested objects manually in AfterMap.Entities/DTOs that carry extra properties (implement IHasExtraProperties) should map them explicitly: .MapExtraProperties() (AutoMapper) or [MapExtraProperties] (Mapperly). Do this when both sides are extensible objects.
Once a source→destination mapping exists, ABP maps collections automatically. Supported: IEnumerable<T>, ICollection<T>, Collection<T>, IList<T>, List<T>, and arrays.
var dtos = ObjectMapper.Map<List<User>, List<UserDto>>(users);
Custom typed mapper — implement IObjectMapper<TSource, TDestination> to fully control a specific mapping. ABP auto-discovers and registers it, using it whenever that pair is mapped. It can inject other services.
public class MyCustomUserMapper : IObjectMapper<User, UserDto>, ITransientDependency
{
public UserDto Map(User source) { return new UserDto { /* build a new UserDto */ }; }
public UserDto Map(User source, UserDto destination) { /* set on existing */ return destination; }
}
Contextual mapper — IObjectMapper<TContext> pins a module to its own mapping library, independent of the final application's default. Register it and use it just like IObjectMapper:
context.Services.AddAutoMapperObjectMapper<MyModule>(); // or AddMapperlyObjectMapper<MyModule>()
Then inject IObjectMapper<MyModule>, or set ObjectMapperContext = typeof(MyModule); in an ApplicationService constructor to make the inherited ObjectMapper property use it. Reusable modules use this so they always map with the library they defined profiles for; final applications can ignore it and use the default IObjectMapper.
AddMaps<MyModule>(validate: true) (or AddProfile<MyProfile>(validate: true)) and confirm the app starts without an AutoMapper configuration-validation error — this proves every declared map is complete.ObjectMapper.Map<Source, Dest>(...) for a defined pair and confirm the destination fields are populated as expected..MapExtraProperties() / [MapExtraProperties].IObjectMapper.Map<TSource, TDestination> needs a registered map for that exact pair or it fails.validate defaults to false; enabling it is recommended so incomplete maps are caught at startup.partial (it's a source generator); destination properties with no writable path are silently ignored, and it respects nullable reference types (a non-nullable destination fed a null source risks NullReferenceException).IAbpMapperlyMapper<,> on one class, or map nested objects in AfterMap.CrudAppService.MapToEntityAsync; blanket input→entity auto-mapping is only safe for simple CRUD entities (entity → output DTO is always suitable for auto-mapping, once the map is defined).IHasExtraProperties.MaxDepth = 64 mitigation. Consider migrating to Mapperly or using the LuckyPenny patched package if relevant.What SKILL.md sets; muted values are Claude Code's defaults
/abp-module-development:map-objects-and-dtosfrom abp-module-development
npx claudepluginhub abpframework/abp-skills --plugin abp-module-development13 skills in this plugin
/application-servicesWrites or reviews an ABP application service — the DTO-taking, DTO-returning boundary between the domain and the presentation/API layer. USE FOR: implementing IApplicationService/ApplicationService for non-CRUD use cases, using AbstractKeyCrudAppService for composite or non-standard keys, and unit-of-work basics. DO NOT USE FOR: exposing application services as auto/conventional API controllers, routes, verbs or [RemoteService] (use expose-http-apis); a complete standard-key CrudAppService workflow (use build-crud-application-services); detailed object-to-DTO mapping mechanics/profiles (use map-objects-and-dtos); DTO validation attributes and business exceptions (use handle-validation-and-errors); permission definitions and authorization policy (use permissions-and-authorization); the overall layered project structure (use layered-architecture).
/build-crud-application-servicesBuilds or reviews a complete ABP CRUD application-service contract and implementation with the CrudAppService APIs. USE FOR: choosing ICrudAppService/CrudAppService generic overloads, separating get/list/create/update DTOs, wiring IRepository, object mappings and five policy properties, adding list filters without breaking count/sort/page order, and validating all five CRUD operations. DO NOT USE FOR: a non-CRUD use case or general ApplicationService orchestration (use application-services); composite or non-standard keys with AbstractKeyCrudAppService (use application-services); mapping-provider configuration details (use map-objects-and-dtos); permission definitions (use permissions-and-authorization); optimistic concurrency (use handle-optimistic-concurrency); HTTP endpoint conventions (use expose-http-apis); integration-test infrastructure (use test-abp-applications).
Other plugins' skills for the same job