我在项目中使用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"
。
如何解决此问题?