Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Description for navigation property #2367

Closed
janseris opened this issue May 31, 2024 · 5 comments
Closed

[Feature request] Description for navigation property #2367

janseris opened this issue May 31, 2024 · 5 comments
Labels

Comments

@janseris
Copy link

janseris commented May 31, 2024

Hi,
I use SQL Server where I put comments on foreign keys in database schema.
I noticed that they are scaffolded on the int property.
However there is nothing displayed on the navigation property which is directly related.
Moreover, I thought that adding Description to the FK constraint itself might add description to the navigation property but that did not do anything either.

My feature request then is that if the Description for the foreign key could be shown on navigation property as well?

/// <summary>
/// Určuje ještě kategorizování oborů, je-li definováno a je-li to potřeba kvůli počtu oborů
/// </summary>
public int? SkupinaOboruUrednichOpravneniID { get; set; }

public virtual SKUPINA_OBORU_OPRAVNENI SkupinaOboruUrednichOpravneni { get; set; }

obrazek

Why (my own scenario but I believe there are countless uses for this):

  • I needed to put a note that the navigation property might be null so that backend programmer can see it when making queries.
    So the note would be showing here:
    obrazek

Thank you

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 1, 2024

Looks similar to #1640

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 3, 2024

@janseris Are you OK with a T4 based solution, then I will try to create a sample similar to issue #1640

@janseris
Copy link
Author

janseris commented Jun 3, 2024

@janseris Are you OK with a T4 based solution, then I will try to create a sample similar to issue #1640

It would be better if this was an option in the options GUi window when scaffolding database.
Me and my colleagues are not familiar with T4 and I think that anyone other who possibly would like this feature, would see that as obstacle and instead choose to skip the idea.

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 3, 2024

Got it, but for this it is either T4 or an EF Core change. It is not something I plan to special case in EF Core Power Tools.

@ErikEJ ErikEJ added enhancement New feature or request reveng reveng-cli labels Jun 11, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Jun 11, 2024

You can modify the T4 template for EntityType like this:

            var comment = navigation.ForeignKey.Properties.FirstOrDefault()?.GetComment();
            if (!string.IsNullOrEmpty(comment))
            {
#>
    /// <summary>
    /// <#= code.XmlComment(comment, indent: 1) #>
    /// </summary>
<#
            }

            var needsNullable = Options.UseNullableReferenceTypes && !(navigation.ForeignKey.IsRequired && navigation.IsOnDependent);

(Last line is original)

@ErikEJ ErikEJ closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
@ErikEJ ErikEJ mentioned this issue Jun 11, 2024
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants