Open Closed

Problem with non-default-named associations in ABP Studio #10831


User avatar
0
haepeto created

In my solution, there is a association between two entities Pilot and Customer, Pilot belongs to 0..1 Customer, and for business reasons, this association has not been named Pilot.Customer but Pilot.Partner. This has been set up properly in the ABP Suite metadata file as: (from pilot.json)

"NavigationProperties": [ { "EntityNameWithDuplicationNumber": "Partner", "EntitySetNameWithDuplicationNumber": "Partners", "ReferencePropertyName": "Partner", "UiPickType": "Typeahead", "IsRequired": false, "IncludeEntitiesFromModules": false, "FromAbpModule": false, "Name": "PartnerId", "DisplayProperty": "Name", "Namespace": "TVRS.People", "EntityName": "Customer", "EntitySetName": "Partners", "DtoNamespace": "TVRS.People", "DtoEntityName": "CustomerDto", "Type": "Guid", "IsFilterable": true } ],

The first time it worked perfectly. A few days later, when I had to make changes to Polit and related entities, I went wrong, and all of the Partner properties and fields where change to Customer. This could have been while upgrading the ABP framework from 10.0 to 10.3 and 10.4, or after upgrading ABP Studio.

It even gets worse, because the metadata of all the Child entities also contains the association that is now broker by ABP.

Every time I use the generator again, I have to do a lot of cleanup changes, until the solution builds again, and I can finally do a database update in EF. It is horrible.

Can you please explain how I got in this mess, and when ABP Studio / Suite will be fixed from this bug? Or, if there is something i can do to avoid it, let me know. But I definitely want to keep the "Partner" notion.

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

3 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Keep the “Partner” notion: ABP Suite/Studio can work with non-default navigation names (like Pilot.Partner pointing to Customer) because the navigation property form/metadata is not limited to EntityName-based naming. Your JSON snippet shows you already configured a custom navigation name (ReferencePropertyName: "Partner" etc.), and that’s a valid approach.

    • How you likely got into this mess (what’s happening)
      When you click Save and generate again, ABP Suite/Studio re-generates multiple code artifacts based on the entity definition + navigation definition. In some versions/flows, Suite/Studio may fall back to convention-based naming (using the target entity name like Customer) in some generated DTOs / “WithNavigationProperties” models and UI pieces, even if your FK/name is customized. This kind of mismatch has been reported historically as a Suite inconsistency around naming navigation properties (especially in “WithNavigationProperties” / DTO generation), and it matches your symptoms: your FK/name stays as you intended in one place, but regenerated classes/pages revert to using the referenced entity’s name (Customer) elsewhere.
      A related, older report exists here (not your exact “Partner becomes Customer everywhere”, but the same category: Suite not consistently honoring the specified navigation property name in generated navigation DTOs): https://abp.io/support/questions/3291

    • Why it “spreads” into child entities / breaks the solution Once Suite/Studio generates mismatched names (e.g., Customer in some places and Partner in others), subsequent runs can treat the project’s current code as input signals (assemblies scanned, existing DTOs/classes found), and the next regeneration can propagate the convention name further—resulting in a cascade of incorrect renames and compilation errors.

    • What you can do today to avoid repeated cleanup (practical mitigation)

      1. Stop re-generating the affected entities/pages once you have manual fixes, unless you are ready to re-apply them. Suite/Studio code generation is not a “round-trip-safe” refactoring tool; it’s primarily a generator.
      2. If you must re-generate: re-verify the navigation property fields in the UI before generating (especially the “property name” / “reference property name” fields) and ensure they still show Partner (not auto-filled back to Customer) right before you click generate.
      3. Prefer a stable naming setup with explicit property names for navigation properties. Suite has had improvements around explicitly naming navigation properties (instead of auto-numbering / auto-naming by entity), highlighted in the migration notes: https://abp.io/docs/10.4/release-info/migration-guides/abp-9-0
        Even though that note talks about “multiple navigation properties”, the key point is: Suite increasingly expects/benefits from explicit naming rather than relying on conventions.
      4. If you are using ABP Studio’s generator on top of an already-generated module, consider limiting regeneration to the minimum set of layers/pages (where possible), because the more layers you regenerate, the more likely the naming inconsistency will ripple.
    • When will it be fixed? I can’t give you a definitive “fixed in version X” for this exact Partner→Customer regression because I don’t have a verified release note or ticket reference that explicitly matches your scenario. The closest verified/public evidence I can point to is that Suite has had known issues around navigation naming consistency (see the support ticket above), and that naming behavior has been actively improved across versions (see the migration guide note above).

    Sources (verified):

    • https://abp.io/support/questions/3291
    • https://abp.io/docs/10.4/release-info/migration-guides/abp-9-0
    • https://abp.io/docs/10.4/suite/generating-crud-page

    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.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    haepeto created

    The AI clearly understood my problem, but the workarounds are not feasible. Please let me know in which (future) version of the framework this will be fixed.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    This is a bug in Suite's navigation property edit dialog. Opening an existing navigation property resets the "Property name", entity set name and DTO name fields back to the defaults derived from the target entity name, so PartnerId becomes CustomerId in the form. The metadata itself is only overwritten when you confirm the dialog with OK and then save the entity — after that, the next generation renames everything to Customer. Clicking Cancel leaves the metadata unchanged. It's not related to the framework or Studio upgrade.

    To repair your solution, set these five fields back in every affected navigation-property entry under .suite/entities — including the entries in the child entity JSON files — and regenerate:

    {
      "Name": "PartnerId",
      "ReferencePropertyName": "Partner",
      "EntitySetName": "Partners",
      "EntityNameWithDuplicationNumber": "Partner",
      "EntitySetNameWithDuplicationNumber": "Partners"
    }
    

    If you created or applied an EF Core migration while the metadata contained the reset names, the JSON repair does not revert that migration — check those migrations separately.

    The name-reset bug is still present in 10.6.0; no released Suite version contains the fix yet. We've fixed it and it will be included in the upcoming patch releases. Until then, re-check the custom names in that dialog before clicking OK (Cancel is fine).

    One more note for your Angular app: on 10.3/10.4 the generated Angular lookup methods and URLs don't match the backend routes for renamed navigation properties (customer-lookup vs partner-lookup). Upgrading to 10.6.0 fixes this Angular part (not the name-reset bug above).

    Thanks

    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 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.