entity-framework-coremodelmetadataef-model-builder

How can I get the EF Core model configuration entity property comment set in HasComment as the html title attribute


Trying to set the title attribute of an html element as the parameter passed to the entity.Property().HasComment(comment) method.

I've tried with no luck:

<label asp-for="OrganizationTypeId" title="@ViewData.ModelMetadata.Description">

The value is null while the OnModelCreating method is setting the following:

modelBuilder.Entity<Organization>(entity =>
{
   entity.Property(e => e.OrganizationTypeId).HasComment("Foreign key of the Org...");

Is this comment available to be used as an html attribute?

Thanks


Solution

  • This DbContext extension method shows how to retrieve comments for a model.