Repository navigation
Preserve model-level SQL Server HiLo sequences in snapshots - #39325
Merged
Merged
Conversation
- Fall back to the model's HiLo sequence name and schema when generating property configuration.\n- Cover inherited sequence settings, explicit property overrides, and snapshot roundtrips.\n\nFixes #39324 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 736c05ed-1c93-423e-99fc-f6298c341738
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fix preserves existing overrides and model-level behavior, with focused regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #39324 by preserving inherited SQL Server HiLo sequence settings in migration snapshots, preventing extra default sequences and false model differences.
Changes:
- Falls back to model-level sequence names and schemas for property-level
UseHiLo. - Preserves explicit property overrides and model-level generation.
- Adds generator and snapshot-roundtrip regression coverage.
| File | Description |
|---|---|
| test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs | Tests inherited settings and explicit overrides. |
| test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs | Tests sequence preservation through snapshot roundtrips. |
| src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs | Adds model-level fallback for property HiLo generation. |
Review effort: Balanced
Code coverage overviewLanguages: C# C# / code-coverage
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
AndriySvyryd
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39324.
Related context: npgsql/efcore.pg#3613.
When generating property-level
UseHiLo, fall back to the model's sequence name and schema if the property has no corresponding annotations. This prevents snapshots from creating an extra default sequence, repeatedDropSequencemigrations, and false pending-model changes. Explicit property overrides and model-level code generation remain unchanged.Regression tests cover default/custom names and schemas, property overrides, and compiled snapshot roundtrips with empty model differences. Confirmed the new tests fail before the fix.
Validation (using
. ./activate.shafter bootstrapping the repository SDK/runtime):dotnet test test/EFCore.SqlServer.Tests/EFCore.SqlServer.Tests.csproj -- --filter-class '*SqlServerAnnotationCodeGeneratorTest'— passed, 27 tests.dotnet test test/EFCore.Design.Tests/EFCore.Design.Tests.csproj -- --filter-class '*CSharpMigrationsGeneratorTest'— passed, 171 tests.