有没有一种使用流畅配置在属性/列上创建索引的方法,而不是使用新的IndexAttribute
?
有没有一种使用流畅配置在属性/列上创建索引的方法,而不是使用新的IndexAttribute
?
目前,在.net core上,它将是:
[Index(nameof(AdvId), IsUnique = true)]
public class tblAdvertisement
{
public int Id { get; set; }
public int AdvId { get; set; }
public DateTime Created { get; set; }
}
因此,属性集在类上而不是成员上。输出迁移在此之后看起来像这样:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Advertisements_AdvId",
table: "Advertisements",
column: "AdvId",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Advertisements_AdvId",
table: "Advertisements");
}