Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Jan 23, 2026

Closes #3710

Copilot AI review requested due to automatic review settings January 23, 2026 15:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements support for PostgreSQL 18's PERIOD feature for foreign keys with temporal tables, closing issue #3710. The PERIOD feature allows foreign keys to reference temporal data by treating the last column (which must be a range type) as a temporal period, enabling proper referential integrity for time-based relationships.

Changes:

  • Added WithPeriod() extension methods for configuring foreign keys with the PERIOD feature
  • Implemented validation to ensure PERIOD is only used with PostgreSQL 18+, requires the principal key to have WITHOUT OVERLAPS, and requires the last column to be a range type
  • Extended migration SQL generation to produce correct PERIOD syntax in foreign key constraints
  • Added scaffolding support to detect and preserve PERIOD annotation when reverse-engineering databases

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/EFCore.PG/Extensions/BuilderExtensions/NpgsqlForeignKeyBuilderExtensions.cs New file providing WithPeriod() fluent API methods for configuring foreign keys
src/EFCore.PG/Extensions/MetadataExtensions/NpgsqlForeignKeyExtensions.cs New file with metadata extension methods for getting/setting PERIOD annotation
src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationNames.cs Added Period annotation constant
src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs Added annotation propagation for foreign key constraints with PERIOD
src/EFCore.PG/Infrastructure/Internal/NpgsqlModelValidator.cs Added validation for PERIOD feature requirements (version, range type, WITHOUT OVERLAPS on principal)
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs Overrode ForeignKeyConstraint to generate proper PERIOD syntax in SQL
src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs Added detection of conperiod field when scaffolding foreign keys
src/EFCore.PG/Properties/NpgsqlStrings.resx Added error message resources for PERIOD validation, plus whitespace cleanup
src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs Generated code for new error message accessors
test/EFCore.PG.Tests/Infrastructure/NpgsqlModelValidatorTest.cs Added test for WITHOUT OVERLAPS validation on PERIOD foreign keys
test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs Added tests for creating and altering foreign keys with PERIOD
Files not reviewed (1)
  • src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 24, 2026 08:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • src/EFCore.PG/Properties/NpgsqlStrings.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roji roji enabled auto-merge (squash) January 24, 2026 08:54
@roji roji merged commit bd07c34 into npgsql:main Jan 24, 2026
16 checks passed
@roji roji deleted the Period branch January 24, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support PERIOD for foreign keys with temporal tables

1 participant