EF Core 10 Introduces Named Default Constraints to Simplify SQL Server Migrations
EF Core 10 adds support for named default constraints in SQL Server, replacing unpredictable system-generated names like DF__Jobs__Status__ with stable, readable ones such as DF_Jobs_Status. Developers can enable this globally via UseNamedDefaultConstraints() in OnModelCreating, or assign names individually through HasDefaultValue and HasDefaultValueSql. Enabling the convention on an existing model triggers a migration that renames every default constraint, generating DROP CONSTRAINT and re-add operations for each affected column. Developers can preview the full migration SQL locally without a live database connection using the dotnet-ef migrations script command. Reviewing the generated script is recommended to assess potential locking behavior and deployment duration before applying changes to production.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in