Skip to content

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
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

3 participants