我在项目中使用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"
。
如何解决此问题?
答案 0 :(得分:0)
这是一个3.0错误#17474: Entity comments overwrites property comments。
已经修复,但是不幸的是,该修复程序将在3.1版本中提供。
在那之前您无能为力。