【问题标题】:How can I get the EF Core model configuration entity property comment set in HasComment as the html title attribute如何获取在 HasComment 中设置的 EF Core 模型配置实体属性注释作为 html 标题属性
【发布时间】:2020-10-05 23:46:04
【问题描述】:

尝试将html元素的title属性设置为传递给entity.Property().HasComment(comment)方法的参数。

我试过没有运气:

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

当 OnModelCreating 方法设置以下内容时,该值为 null:

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

此评论是否可用作 html 属性?

谢谢

【问题讨论】:

  • 请参阅the following DbContext 扩展方法,该方法显示如何检索模型的 cmets,但确实提供了显示 cmets 的完整路径。 following 以 Windows 形式显示使用情况(是的,它不是 ASP.NET),但提供了如何获取模型的 cmets 的想法。应该足以用于您的代码。

标签: entity-framework-core modelmetadata ef-model-builder


【解决方案1】:

This DbContext extension method 展示了如何检索模型的 cmets。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 2020-04-16
    • 2017-01-15
    相关资源
    最近更新 更多