Skip to content

SqlServer FillFactor for PK is missing #32803

@bryanhunwardsen

Description

@bryanhunwardsen

"FillFactor" was added several versions ago but it is incomplete/broken.
.HasFillFactor() is only settable on explicit/defined Indexes.
In SqlServer, FillFactor can be set on the PK without additional complexity to the Schema.
This is not available with the FillFactor implementation of EFC 8.
This is an incomplete implementation of the feature which is why I am filing as a bug and not as a feature request.

To advertise FillFactor is supported in EF, code like this:

builder.HasKey(x => x.Id).HasFillFactor(90);

Should produce Sql Schema as:

CREATE TABLE [dbo].[MyTable](
	[Id] [int] IDENTITY(1,1) NOT NULL
 CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

or at a minimum, provide a fluent option that ultimately executes the following sql as it will cover the PK:

ALTER TABLE MyTable REBUILD WITH (FILLFACTOR = 90);
GO

EF Core version: 8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Win10
IDE: Visual Studio 2022 17.4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions