Open Closed

AutoMapper to Mapper migration #10520


User avatar
0
DominaTang created

When upgrade from ABP8 to ABP 10, follow Mapperly migration guide web page, the old code just simply sentence to map from IdentityUser to IdentityUserEto, with new code:


3 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • The compiler error you’re seeing (CS8795: “Partial method … must have an implementation part because it has accessibility modifiers”) happens when the Mapperly source generator doesn’t run / doesn’t generate code for that [Mapper] class.
      In that case, your public override partial … Map(...) declarations remain “unimplemented”, and C# reports CS8795.

    • In ABP v10, the correct pattern (public override partial ...) is valid only if:

      1. the project references Mapperly (and ABP’s Mapperly integration), and
      2. the Mapperly source generator is executed during build, producing the other part of the partial class.

    Fix (step-by-step)

    1. Ensure you installed ABP Mapperly integration package in the project where the mapper class exists:

      • Volo.Abp.Mapperly
    2. Ensure the module registers Mapperly (at least in that layer):

    using Volo.Abp.Modularity;
       using Volo.Abp.Mapperly;
    
       [DependsOn(typeof(AbpMapperlyModule))]
       public class YourModule : AbpModule
       {
           public override void ConfigureServices(ServiceConfigurationContext context)
           {
               context.Services.AddMapperlyObjectMapper<YourModule>();
               // or (if you want it as default provider)
               // context.Services.AddMapperlyObjectMapper();
           }
       }
    
    1. Ensure the Mapperly generator package is present (directly or transitively). If CS8795 persists, add it explicitly to the same .csproj where the mapper lives:
    <ItemGroup>
         <PackageReference Include="Riok.Mapperly" Version="*" PrivateAssets="all" />
       </ItemGroup>
    

    Then Clean + Rebuild (not just Build).

    1. Make sure the mapper class is in a buildable project (not a shared project with generation disabled) and that you are not disabling analyzers/source generators (e.g., <RunAnalyzers>false</RunAnalyzers> or similar build settings).

    After these, the generated file for your mapper should appear under Dependencies → Analyzers → Riok.Mapperly (VS) / Generated files, and the CS8795 error will disappear.

    • https://abp.io/docs/10.0/release-info/migration-guides/AutoMapper-To-Mapperly
    • https://abp.io/docs/latest/framework/infrastructure/object-to-object-mapping
    • https://abp.io/community/articles/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.

  • User Avatar
    0
    DominaTang created

    I checked all steps you mentioned, under Dependencies -> Analyzers -> Rick.Mapperly, there is empty class generated

    public partial class IdentityUserToIdentityUserEtoMapper
    {
    }
    

    }

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What is your VS version?

    targeting .NET 10 is only officially supported in Visual Studio 2026 and later versions

    Thanks.

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.3.0-preview. Updated on March 13, 2026, 12:51
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.