Open Closed

how to replace EntityHelper or any other helper #5852


User avatar
0
mmaldonado@emscltd.com created
  • ABP Framework version: 6.0.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: Guid generated using EntityHelper.TrySetId does not match the standard for GUID
  • Steps to reproduce the issue: Create an entity and wait for id generation

I would like to know:

1: how to replace or override a function over EntityHelper or any other static helper. EntityHelper.TrySetId is causing a lot of problems on my system, the GUIDs do not match the standard for GUIDs [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[afA-F0-9]{12}

2: if it is possible to stop the Id generation setting as default configuration on module setup

3: One example of how to use DisableIdGenerationAttribute


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

    You can replace the IGuidGenerator service.

    For example:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IGuidGenerator))]
    public class MyGuidGenerator : IGuidGenerator, ITransientDependency
    {
        public virtual Guid Create()
        {
            return Guid.NewGuid();
        }
    }
    
    

    You need to use the DisableIdGenerationAttribute

    3.

    For example:

    public class MyEntity : AggregateRoot<Guid>
    {
        [DisableIdGeneration]
        public override Guid Id { get; protected set; }
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09