Open Closed

how to replace EntityHelper or any other helper #5852


User avatar
0
dev_marcelo 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

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    1
    liangshiwei created
    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; }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.