Skip to content

HasFillFactor only gets applied when database is altered, not when created #33269

@ajcvickers

Description

@ajcvickers
modelBuilder.Entity<FirstEntry>()
    .HasKey(e => e.Id)
    .HasFillFactor(10)
    .HasName("MyKey");

If this change is made to an existing table, then the fill-factor is set:

ALTER TABLE [FirstEntry] DROP CONSTRAINT [MyKey];
GO

ALTER TABLE [FirstEntry] ADD CONSTRAINT [MyKey] PRIMARY KEY ([Id]) WITH (FILLFACTOR = 10);
GO

But if it is done for the table creation, then the fill-factor is missing:

CREATE TABLE [FirstEntry] (
    [Id] int NOT NULL IDENTITY,
    [Token] int NOT NULL,
    CONSTRAINT [MyKey] PRIMARY KEY ([Id])
);

Same is true for HasFillFactor on indexes.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions