Skip to content

[Feature] Add option to add attributes on navigation properties for the entity #547

Open

Description

@ArnaudB88

In our company, we use your generator for many years now with many developers. Over the years, we added some features so it works better with our solutions. As a sign of appreciation, I want to suggest some features because I think it will help some other developers as well.

Feature description:

Add an option to add attributes on navigation properties in the generated entity classes.

Feature motivation & example usage:

We use it to add the 'Ignore' attribute from Automapper on all navigation properties. In combination with an automapper config, we exclude mappings for all destinationmember properties which have that attribute. This allows mapping dto classes to entities without mapping the navigation properties. We want to map them explicitly in code, since we work with soft deletes.

This is only one example, but I can immagine other examples. The alternative to this feature would be a manual addition, but that is a lot of work and a regeneration would rollback all additions.
The option is a ; separated string, so multiple attributes can be added.

YAML usage:

data:
  entity:
    relationshipAttributes: 'Ignore'

Code generation result:

public partial class Project
{
    #region Generated Relationships
    [Ignore]
    public virtual ICollection<Item> Items { get; set; }
    #endregion
}

Please review the feature request and evaluate if you think this is an addition to your repo.
(pull request will be added)

Thanks

Activity

  1. added a commit that references this issue on Mar 22, 2024
  2. github-actions commented on Jun 21, 2026

    @github-actions
    Contributor

    ⏰ Stale Issue

    This issue has had no activity for 1 year.
    It will be closed in 45 days unless there is new activity.
    To keep it open, comment or remove the stale label.

  3. ArnaudB88 commented on Jun 23, 2026

    @ArnaudB88
    Author

    I updated the PR with the latest master. Is it possible to add this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions