Open Closed

Elsa Workflow issues after updating to abp 7.1 #4920


User avatar
0
neethucp created

We have integrated elsa workflow to abp project. It was all working fine with abp v7.0.3. But when we updated abp to version 7.1 following issues started happening

  1. Unable to access elsa dashboard api's as automapper mappings configured in elsa package stopped working.
  2. Elsa workflow instances doesn't save properly when updated, as entity change tracking doesn't work. Elsa gets the entity from the database and maps the latest changes to the entity using automapper and then saves the dbcontext. But the entity is in detached state after mapping and hence changes not saved.

Can you please shed some light on what changed with the version 7.1 that might be causing this issue. Elsa is also using .net 7 and automapper version 12.0.0.

  • ABP Framework version: v7.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can check this: https://github.com/abpframework/abp/issues/16201

  • User Avatar
    0
    neethucp created

    Hi, we have added the automapping for elsa dashboard manually. And the dashboard issue is sorted. But major issue we are facing is with workflow instance not getting updated. Following is the code in elsa to save the instance. On debugging we found that entity is in detached state and hence change tracking not working for update. https://github.com/elsa-workflows/elsa-core/blob/392b4509217bf1c2b8c90a4ed669bc71ab45f4ab/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Core/Stores/EntityFrameworkStore.cs

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Can you please shed some light on what changed with the version 7.1 that might be causing this issue. Elsa is also using .net 7 and automapper version 12.0.0.

    There is no breaking changes from 7.0 to 7.1, can you reproduce this issue with a new project and share it with me? shiwei.liang@volosoft.com I will check it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It's a bug we will fix it in the patch version.

    You can try this:

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddSingleton<AutoMapper.IConfigurationProvider>(sp =>
        {
            using (var scope = sp.CreateScope())
            {
                var options = scope.ServiceProvider.GetRequiredService<IOptions<AbpAutoMapperOptions>>().Value;
    
                var mapperConfigurationExpression = sp.GetRequiredService<IOptions<MapperConfigurationExpression>>().Value;
                var autoMapperConfigurationContext = new AbpAutoMapperConfigurationContext(mapperConfigurationExpression, scope.ServiceProvider);
    
                foreach (var configurator in options.Configurators)
                {
                    configurator(autoMapperConfigurationContext);
                }
                var mapperConfiguration = new MapperConfiguration(mapperConfigurationExpression);
    
                foreach (var profileType in options.ValidatingProfiles)
                {
                    mapperConfiguration.Internal().AssertConfigurationIsValid(((Profile)Activator.CreateInstance(profileType)).ProfileName);
                }
    
                return mapperConfiguration;
            }
        });
    
        context.Services.AddTransient<IMapper>(sp => sp.GetRequiredService<AutoMapper.IConfigurationProvider>().CreateMapper(sp.GetService));
    
        context.Services.AddTransient<MyMapperAccessor>(sp => new MyMapperAccessor()
        {
            Mapper = sp.GetRequiredService<IMapper>()
        });
        context.Services.AddTransient<IMapperAccessor>(provider => provider.GetRequiredService<MyMapperAccessor>());
        
    }
    
    public class MyMapperAccessor : IMapperAccessor
    {
        public IMapper Mapper { get; set; }
    }
    
  • User Avatar
    0
    neethucp created

    That fixed the issue. Thank you.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09