You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Did the naming convention change for HasCheckConstraint in v.6? Is this a breaking change? #27059
When you generate a migration using dotnet ef migrations add foo using .Net 5 and EF Core 5.0.13 (libraries and tool), the migration output includes the following:
Ah, thanks. Sorry, I missed that in the docs. I even saw that section but I think my brain shut off because I wasn't doing anything that was related to uniqueness, so it didn't register that that mitigation applied.
At the end of the day, in our actual application, we're using IMutableEntityType.AddCheckConstraint which doesn't seem to have an overload that supports overriding the name like HasCheckConstraint does. (The name parameter passed to AddCheckConstraint is still going through the convention mutation apparently.) We ended up just going the "when in Rome" route and changed the name of all our constraints, but it's good to know this is expected behavior at least. Thanks for pointing that out.
Activity
ajcvickers commentedon Jan 6, 2022
Note for triage: verified that the constraint name is changed to "CK_Records_CHK_Records_Id" in 6.0.
Migration with 5.0:
Migration with 6.0:
AndriySvyryd commentedon Jan 6, 2022
This is a known breaking change: https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/breaking-changes#unique-check-constraints
The store name needs to be specified using
HasName:modelBuilder.Entity<Record>().HasCheckConstraint("Id", "[Id] > 10", c => c.HasName("CHK_Records_Id"));davemateer commentedon Jan 7, 2022
Ah, thanks. Sorry, I missed that in the docs. I even saw that section but I think my brain shut off because I wasn't doing anything that was related to uniqueness, so it didn't register that that mitigation applied.
At the end of the day, in our actual application, we're using
IMutableEntityType.AddCheckConstraintwhich doesn't seem to have an overload that supports overriding the name likeHasCheckConstraintdoes. (Thenameparameter passed toAddCheckConstraintis still going through the convention mutation apparently.) We ended up just going the "when in Rome" route and changed the name of all our constraints, but it's good to know this is expected behavior at least. Thanks for pointing that out.Stop prefixing check constraints.
AndriySvyryd commentedon Jan 7, 2022
@davemateer You can set
IMutableCheckConstraint.Name, thenamepassed toAddCheckConstraintis actuallyModelName.We discussed this again and decided to revert the prefixing change, as it's unexpected and unnecessary.
Stop prefixing check constraints.
Stop prefixing check constraints.
Stop prefixing check constraints.
Stop prefixing check constraints.
Remove quirk for #27059
Remove quirk for #27059 (#27147)