Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ajcvickers opened this issue Mar 7, 2024 · 1 comment · Fixed by #33407
Closed

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

ajcvickers opened this issue Mar 7, 2024 · 1 comment · Fixed by #33407
Labels
area-migrations area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Member

ajcvickers commented Mar 7, 2024

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.

@ajcvickers
Copy link
Member Author

Related to #32803, which was implemented by @deano-hunter in #32900

@ajcvickers ajcvickers assigned ajcvickers and unassigned maumar Mar 26, 2024
@ajcvickers ajcvickers added this to the 9.0.0 milestone Mar 26, 2024
ajcvickers added a commit that referenced this issue Mar 26, 2024
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 26, 2024
ajcvickers added a commit that referenced this issue Mar 27, 2024
* Apply fill factor when creating tables

Fixes #33269

* Updated to remove KeyTraits and use IndexOptions
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview4 Mar 27, 2024
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
@roji roji modified the milestones: 9.0.0-preview4, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants