Don't skip creating cascade delete on SQL Server when types are base-linking across tables#28965
Merged
ajcvickers merged 2 commits intorelease/7.0from Sep 2, 2022
Merged
Don't skip creating cascade delete on SQL Server when types are base-linking across tables#28965ajcvickers merged 2 commits intorelease/7.0from
ajcvickers merged 2 commits intorelease/7.0from
Conversation
AndriySvyryd
reviewed
Sep 2, 2022
|
|
||
| if (foreignKey.IsBaseLinking()) | ||
| if (foreignKey.IsBaseLinking() | ||
| && IsMappedToSameTable(foreignKey.DeclaringEntityType, foreignKey.PrincipalEntityType)) |
Member
There was a problem hiding this comment.
Base linking FKs on the same table wouldn't be created in the database, since they are redundant, so we can just remove this
Contributor
Author
There was a problem hiding this comment.
If I remove this, then "Entity_splitting_is_stored_in_snapshot_with_tables" fails. Not sure what the correct behavior should be for entity splitting.
Contributor
Author
There was a problem hiding this comment.
b.HasOne(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+Order"", null)
.WithOne()
.HasForeignKey(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+Order"", ""Id"")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
Contributor
Author
|
@AndriySvyryd Updated. |
AndriySvyryd
approved these changes
Sep 2, 2022
…linking across tables E.g. for TPT. Fixes #28532 (Cascade delete behavior for FK between PKs in TPT) Note this is a breaking change--creating a cascade delete for the TPT relationship could cause a cycle with another existing cascade relationship. This is what happened with the GearsOfWar model.
76fe355 to
375b789
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
E.g. for TPT.
Fixes #28532 (Cascade delete behavior for FK between PKs in TPT)
Note this is a breaking change--creating a cascade delete for the TPT relationship could cause a cycle with another existing cascade relationship. This is what happened with the GearsOfWar model.