-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Detaching an entity results in related entities being deleted #18982
Comments
Hello, has anyone noticed this? I'd say this is a pretty serious bug, no? |
Note for triage: this still repros with 3.1. It looks like detaching the principal is causing cascade delete of the dependents rather than cascade detach. @shaulbehr We will investigate whether this is something we should patch. |
@shaulbehr It looks like a workaround might be to revert the change to the cascade timing using something like this: public BloggingContext()
{
ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges;
ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges;
} Can you test if this workaround works for you? |
@ajcvickers Yep, that workaround works. Thanks! |
Please fix this soon as possible! For me the Expected behavior is the related objects should not be deleted; rather their tracking status should REMAIN the same - it shouldn’t be affected - it’s the beahvior of EF6 and EFCore 2.2. Thanks |
…elete issues We made tweeks to the cascade delete behavior in 3.0 and also changed the default timing for when cascades happen. This change introduced several bugs which all result in deletion or severing of relationships instead of detaching them. This was then hit by more people due to the timing change. Issues: #19203 #19137 #18982 #16546
…elete issues We made tweeks to the cascade delete behavior in 3.0 and also changed the default timing for when cascades happen. This change introduced several bugs which all result in deletion or severing of relationships instead of detaching them. This was then hit by more people due to the timing change. Issues: #19203 #19137 #18982 #16546
@silvajpr This is approved for the 3.1.3 patch, tentatively scheduled for March. |
…elete issues We made tweeks to the cascade delete behavior in 3.0 and also changed the default timing for when cascades happen. This change introduced several bugs which all result in deletion or severing of relationships instead of detaching them. This was then hit by more people due to the timing change. Issues: #19203 #19137 #18982 #16546
@ajcvickers do you have an ETA for 3.1.3 patch release? |
@YZahringer It's still tentatively scheduled for March. |
Is this fixed? |
EF Core 3.0.1
I insert an object along with related objects. Then I set the state of the object to "Detached". I then perform another call to
.SaveChangesAsync()
.Observed behavior: the related objects are deleted.
Expected behavior: the related objects should not be deleted; rather their tracking status should simply be set to "Detached".
(This is a breaking change since upgrading from EF Core 2.2.4)
Steps to reproduce
Result:
Further technical details
EF Core version: 3.0.1
Database provider: Npgsql
Target framework:.NET Core 3.0
Operating system: Windows 10 Pro
IDE: JetBrains Rider
The text was updated successfully, but these errors were encountered: