Skip to content

Fix to #11502 - Allow to specify constraint name for default values #36067

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

Merged
merged 2 commits into from
May 20, 2025

Conversation

maumar
Copy link
Contributor

@maumar maumar commented May 12, 2025

Adding model builder API to allow specifying explicit constraint name when adding default value (sql) to a column. Also added switch on the model level (opt-in) to switch from system-generated constraints to generating them automatically by name and storing in the model. This is opt-in because we don't want to cause unnecessary migrations. Added de-duplication logic in the finalize model step, in case our generated names happen to clash with ones specified explicitly by user.

Model builder APIs are exposed on the SQL Server level, but a lot of piping is in relational so that providers who support named constraints can take advantage of the feature.

Also split temporal tables migration tests for SqlServer into a separate file - there were way too many tests in MigrationsSqlServerTest

Fixes #11502

Adding model builder API to allow specifying explicit constraint name when adding default value (sql) to a column.
Also added switch on the model level (opt-in) to switch from system-generated constraints to generating them automatically by name and storing in the model.
This is opt-in because we don't want to cause unnecessary migrations.
Added de-duplication logic in the finalize model step, in case our generated names happen to clash with ones specified explicitly by user.

Model builder APIs are exposed on the SQL Server level, but a lot of piping is in relational so that providers who support named constraints can take advantage of the feature.

Also split temporal tables migration tests for SqlServer into a separate file - there were way to many tests in MigrationsSqlServerTest

Fixes #11502
@maumar maumar force-pushed the fix11502_relational branch from 2a63511 to 8b52a06 Compare May 12, 2025 08:07
@maumar
Copy link
Contributor Author

maumar commented May 15, 2025

@AndriySvyryd is probably the best person to look at this

@maumar maumar marked this pull request as ready for review May 15, 2025 18:49
@maumar maumar requested a review from a team as a code owner May 15, 2025 18:49
@AndriySvyryd AndriySvyryd self-requested a review May 15, 2025 18:51
�	Add model builder extention methods for other types of properties
�	Uniquify names using the established pattern in SharedTableConvention
�	Make GetDefaultConstraintName return the generated default constraint name if UseNamedDefaultConstraints was called
@AndriySvyryd AndriySvyryd enabled auto-merge (rebase) May 20, 2025 04:45
@AndriySvyryd AndriySvyryd merged commit 29c055e into main May 20, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the fix11502_relational branch May 20, 2025 05:28
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.

Allow to specify constraint name for default values
2 participants