如何使EntityTypeBuilder用新的方式添加正确的注释?

我在项目中使用Npgsql.EntityFrameworkCore。我这样配置我的实体:

internal class MyEntityConfiguration : IEntityTypeConfiguration<MyEntity>
{
    public void Configure(EntityTypeBuilder<MyEntity> builder)
    {
        builder.HasComment("Entity description");

        builder.Property(e => e.Name)
            .isrequired()
            .HasMaxLength(255)
            .HasComment("Name of entity");

        builder.Property(e => e.Isactual)
            .HasComment("Is entity actual");
    }
}

由于ForNpgsqlHasComment已过时(并且可以正常工作),我们应该使用HasComment,这会导致错误的迁移:

migrationBuilder.Createtable(
    name: "MyEntity",columns: table => new
        {
            Id = table.Column<int>(nullable: false)
                      .Annotation("Npgsql:ValueGenerationStrategy",NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),Name = table.Column<string>(maxLength: 255,nullable: false,comment: "Entity description"),Isactual = table.Column<bool>(nullable: false,comment: "Entity description")
        },comment: "Entity description");

换句话说,在所有注释中使用"Entity description"。 如何解决此问题?

icem_net 回答:如何使EntityTypeBuilder用新的方式添加正确的注释?

这是一个3.0错误#17474: Entity comments overwrites property comments

已经修复,但是不幸的是,该修复程序将在3.1版本中提供。

在那之前您无能为力。

本文链接:https://www.f2er.com/3138430.html

大家都在问