Activities of "johnsonlim"

[AI-Bot] said:

  • ABP Suite can generate “normal” navigation properties (1-N / N-1) between two different entities, but a self-referencing relationship (an entity that has a FK to itself) is not reliably supported by Suite’s CRUD generator. The symptoms you described (not creating the FK/migration as expected, and the custom “Property name” not being persisted especially with a + suffix) are consistent with Suite not handling that scenario well.
  • Workaround (recommended): implement the self-reference manually in your EF Core model and run migrations yourself (you can still use Suite for the rest of the CRUD scaffolding, but don’t rely on it to model this relationship).

Manual self-referencing FK (EF Core) example

Assume entity A should optionally reference a parent A:

1) Domain entity (A.cs)

public class A : AggregateRoot<Guid> 
{ 
    public Guid? ParentAId { get; set; }   // FK column 
    public A? ParentA { get; set; }        // reference nav 
 
    public ICollection<A> ChildAs { get; set; } = new List<A>(); // collection nav 
} 

2) EF Core mapping (in your OnModelCreating / DbContextModelCreatingExtensions)

builder.Entity<A>(b => 
{ 
    b.HasOne(x => x.ParentA) 
     .WithMany(x => x.ChildAs) 
     .HasForeignKey(x => x.ParentAId) 
     .OnDelete(DeleteBehavior.Restrict); // common choice to avoid cascade cycles 
}); 

3) Add migration + update DB Run the standard EF Core migration commands (or use your DbMigrator project) so the column and FK constraint are created.

Important notes for your specific case

  • Do not use special characters like + in property names (Attribute A+). That is not a valid C# identifier and will cause persistence/generation issues in tooling. Use a valid identifier such as ParentA, ParentAId, AttributeAPlus, etc.
  • If you need two separate self-references (e.g., ParentAId and AlternateParentAId), name them explicitly with valid identifiers and map both relationships in EF Core; Suite typically struggles even more with “multiple relationships to the same entity” scenarios.

Sources

  • https://abp.io/docs/latest/suite/generating-crud-page
  • https://abp.io/community/articles/furp75ex

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.

Hi, My another question is that by by doing the changes in code, one day in future, if i use the ABP Suite to generate additional attribute, will i lost the code and the foreign key relation?

Hi All, I tried to create a Self Referencing Foreign Key named "Attribute A+" in table "A" via ABP Suites. After creating the attribute, i learn that the attribute is not created automatically in database as usual even though i have Create Backend, Add Migration, Update Database options checked in ABP Suites. Apart of that, i learn that name of the attribute "Attribute A+" is not kept in ABP Suites after close and reopen. I named the attribute as such "Attribute A+" because ABP Suites does not allow the same name of 2 attribute. I did this under Advanced tab in Navigation Property page.Attahced picture with red highlighed red box is where i fill in the name.

My question is does ABP Suites support Self Referencing Foreign Key? Because apparently it seems to me no. And if ABP Suites does not support,can anyone suggest workaround?

Showing 21 to 22 of 22 entries
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 October 30, 2026, 06:34
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.