Open Closed

Error CS8795 - AutoMapper-To-Mapperly #10412


User avatar
0
LucasFarias created

I'm migrating from AutoMapper to Mapperly. My application is based on ABPFramework, .NET 10.0, Visual Studio 2022 v. 17.14.25.

The problem is that VS generates 294 errors as shown below, one for each mapping class. I tested using VS 2026 and VS Code; they don't generate the error list, but when running the application, the missing mapping appears in the terminal.

Another issue is that when running dotnet run in the CLI, these errors don't appear, not even during compilation, but they do exist.

I've already checked the various documentation, deleted bin and obj files, and tried practically everything available, but the error persists. https://github.com/riok/mapperly/discussions/1431 https://mapperly.riok.app/docs/getting-started/installation/ https://abp.io/docs/10.0/release-info/migration-guides/AutoMapper-To-Mapperly

`using AguiaSistemas.GestaoComercial.WorkflowsPreVendas; using System; using System.Linq; using Riok.Mapperly.Abstractions; using Volo.Abp.Identity; using Volo.Abp.Mapperly; using Volo.FileManagement.Files;

namespace AguiaSistemas.GestaoComercial;

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] public partial class AcessorioToAcessorioDtoMapper : MapperBase<Acessorio, AcessorioDto> { public override partial AcessorioDto Map(Acessorio source);

public override partial void Map(Acessorio source, AcessorioDto destination);

}

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] public partial class AcessorioToAcessorioExcelDtoMapper : MapperBase<Acessorio, AcessorioExcelDto> { public override partial AcessorioExcelDto Map(Acessorio source);

public override partial void Map(Acessorio source, AcessorioExcelDto destination);

}

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] public partial class AcessorioToLookupDtoGuidMapper : MapperBase<Acessorio, LookupDto

[MapProperty(nameof(Acessorio.Nome), nameof(LookupDto<Guid>.DisplayName))]
public override partial void Map(Acessorio source, LookupDto<Guid> destination);

}

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)] public partial class AtividadeToAtividadeDtoMapper : MapperBase<Atividade, AtividadeDto> { public override partial AtividadeDto Map(Atividade source);

public override partial void Map(Atividade source, AtividadeDto destination);

}`

AguiaSistemas.GestaoComercial.Application net10.0 êxito (2,2s) → bin\Debug\net10.0\AguiaSistemas.GestaoComercial.Application.dll


5 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • This CS8795 in Visual Studio is caused by Mapperly source-generator output not being picked up by VS/IntelliSense, so VS thinks your public override partial ... methods have no implementation part (even though dotnet build/run can still succeed sometimes). In ABP v10, your mapper class shape is correct; the problem is the generator not running/being loaded by the IDE consistently.

    • Fix it by ensuring Mapperly’s source generator is referenced as an analyzer in the project which contains the [Mapper] classes (typically your *.Application project), and by enabling compiler-generated files so VS can “see” them.

    Do this (in the project that contains the mapper classes)

    1. Add/verify these package references in the same csproj that contains AcessorioToAcessorioDtoMapper etc.:
    <ItemGroup>
      <PackageReference Include="Volo.Abp.Mapperly" Version="10.0.2" />
      <PackageReference Include="Riok.Mapperly" Version="*" PrivateAssets="all" />
    </ItemGroup>
    
    1. Make sure the Mapperly generator is actually treated as an analyzer (some setups require it explicitly). Add:
    <ItemGroup>
      <Analyzer Include="$(NuGetPackageRoot)riok.mapperly\*\analyzers\dotnet\cs\Riok.Mapperly.Generators.dll" />
    </ItemGroup>
    
    1. Add these properties to help VS/IntelliSense pick up generated code and to verify generation:
    <PropertyGroup>
      <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
      <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\Generated</CompilerGeneratedFilesOutputPath>
    </PropertyGroup>
    
    1. Close Visual Studio, delete .vs, bin, obj, reopen, then Rebuild.

    After rebuild, you should see generated files under: obj\Debug\net10.0\Generated\... and CS8795 should disappear.

    ABP-side registration reminder (so runtime mapping works)

    In your ABP module (Application/Blazor/Host as appropriate), ensure you are using Mapperly registration (not AutoMapper):

    using Volo.Abp.Mapperly;
    
    [DependsOn(typeof(AbpMapperlyModule))]
    public class GestaoComercialApplicationModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddMapperlyObjectMapper<GestaoComercialApplicationModule>();
            // If you want Mapperly as the default provider globally:
            // context.Services.AddMapperlyObjectMapper();
        }
    }
    

    If you still have Volo.Abp.AutoMapper referenced anywhere, remove it from the projects you migrated, otherwise ABP may still try to resolve mappings via AutoMapper in some contexts.

    • https://abp.io/docs/10.0/release-info/migration-guides/AutoMapper-To-Mapperly
    • https://mapperly.riok.app/docs/getting-started/installation/

    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
    LucasFarias created

    The files were not generated in AguiaSistemas.GestaoComercial.Application\obj\Debug\net10.0. And the CS8795 errors remain.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

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

    So you need to use VS 2026 to build and run your app.

    Can you try to add a global.json to your solution and specify the NET 10 SDK version?

    Run abp clean and dotnet build in your solution, then open it in VS 2026 and test again.

    {
      "sdk": {
        "version": "10.0.100",
        "rollForward": "latestFeature",
        "allowPrerelease": true
      }
    }
    

    Thanks.

  • User Avatar
    0
    LucasFarias created

    Hello,

    Yes, I'm using VS 2026, and the SDK is 10.0.102.

    The problem is that, in the IDE 2026, it doesn't generate errors and runs the application, but, for example, when accessing a page, it generates an error about a missing mapping.

    I've already tried all the steps of deleting bin, obj, and rebuilding the application, but nothing has solved it.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a demo project? liming.ma@volosoft.com I will test in my VS 2026.

    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.2.0-preview. Updated on February 17, 2026, 09:10
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.