SQL Server 是否使用Fluent API指定索引填充因子?

ulydmbyx  于 2022-12-10  发布在  其他
关注(0)|答案(2)|浏览(82)

I'm using Entity Framework 7 (.NET Core 1) RC1. I'd like to create some indexes in a Migration. That part is easy enough, but I can't find any examples of how to specify the fill factor for the indexes.
The Context looks something like this:

modelBuilder.Entity<SomeObject>( entity =>
{
    entity.HasIndex( e => e.SomeProperty ).HasName(" IX_SomeObject_SomeProperty" );
}

And the Migration looks something like this:

migrationBuilder.CreateIndex(
    name: "IX_SomeObject_SomeProperty",
    schema: "dbo",
    table: "SomeObject",
    column: "SomeProperty" );

Is this just not supported by Fluent? Will I have to create the index manually in the Migration?

kmb7vmvb

kmb7vmvb1#

EF Core 5.0即将支持该功能。

modelBuilder
    .Entity<Customer>()
    .HasIndex(e => e.Name)
    .HasFillFactor(90);

参考:https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/whatsnew#specify-sql-server-index-fill-factor

s71maibg

s71maibg2#

EF Core RC1不支持填充因子。您可以使用migrationBuilder.Sql手动编写create index语句。

相关问题