0

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

Leo
  • 1
  • 1
  • 1
    See [the following](https://github.com/karenpayneoregon/ef-core-find-csharp/blob/master/EntityCoreExtensions/DbContexts.cs#L70) DbContext extension method which shows how to retrieve comments for a model but does provide a full path to displaying comments. The [following](https://github.com/karenpayneoregon/NorthWind-2020/blob/master/North/Forms/PropertyGetCommentForm.cs) shows usage in a windows form (yeah it's not ASP.NET) but gives an idea how to get comments for a model. Should be enough to work into your code. – Karen Payne Oct 03 '20 at 13:14

1 Answers1

0

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

Leo
  • 1
  • 1
  • The answer will not work with `EF Core 6` as there were changes made on how to get comments, see the version of EF Core 6 [here](https://github.com/karenpayneoregon/ef-core-6-tips/blob/master/EntityFrameworkCoreHelpers/EntityExtensions.cs#L93:L113) – Karen Payne Sep 09 '22 at 19:43