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
Request: A DeleteBehavior that does absolutely nothing on delete and on SaveChanges #8633
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-enhancement
Milestone
Comments
@Wain123 We discussed this at length and came to a couple of conclusions:
|
ajcvickers
added
the
closed-out-of-scope
This is not something that will be fixed/implemented and the issue is closed.
label
May 31, 2017
ajcvickers
added a commit
that referenced
this issue
Jun 5, 2017
…and Restrict in the database Issues #8654, #8632, #8633 The new behavior is called 'ClientSetNull'. 'Restrict' now throws on SaveChanges if EF would have set null. This is the same behavior that has always been there for required relationships, so this is only a break for optional relationships explicitly configured with Restrict, which should be relatively rare since this was the default anyway. The default is now 'ClientSetNull', which matches the old behavior of 'Restrict', so apps that were not setting anything explicitly will not get a breaking change.
ajcvickers
added
type-enhancement
and removed
closed-out-of-scope
This is not something that will be fixed/implemented and the issue is closed.
labels
Jun 5, 2017
Decided to do this as a side-effect of #8654. |
ajcvickers
added a commit
that referenced
this issue
Jun 5, 2017
…and Restrict in the database Issues #8654, #8632, #8633 The new behavior is called 'ClientSetNull'. 'Restrict' now throws on SaveChanges if EF would have set null. This is the same behavior that has always been there for required relationships, so this is only a break for optional relationships explicitly configured with Restrict, which should be relatively rare since this was the default anyway. The default is now 'ClientSetNull', which matches the old behavior of 'Restrict', so apps that were not setting anything explicitly will not get a breaking change.
ajcvickers
added a commit
that referenced
this issue
Jun 5, 2017
…and Restrict in the database Issues #8654, #8632, #8633 The new behavior is called 'ClientSetNull'. 'Restrict' now throws on SaveChanges if EF would have set null. This is the same behavior that has always been there for required relationships, so this is only a break for optional relationships explicitly configured with Restrict, which should be relatively rare since this was the default anyway. The default is now 'ClientSetNull', which matches the old behavior of 'Restrict', so apps that were not setting anything explicitly will not get a breaking change.
ajcvickers
added a commit
that referenced
this issue
Jun 6, 2017
…and Restrict in the database Issues #8654, #8632, #8633 The new behavior is called 'ClientSetNull'. 'Restrict' now throws on SaveChanges if EF would have set null. This is the same behavior that has always been there for required relationships, so this is only a break for optional relationships explicitly configured with Restrict, which should be relatively rare since this was the default anyway. The default is now 'ClientSetNull', which matches the old behavior of 'Restrict', so apps that were not setting anything explicitly will not get a breaking change.
ajcvickers
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Jun 6, 2017
This was referenced Sep 4, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-enhancement
DeleteBehavior.Restrict behaves the same as DeleteBehavior.SetNull for tracked entities, details are in #8342
My problem is that, if I delete an entity and forget to handle its children, EF will simply set their foreign keys to null and let me save the mistake to the DB. It goes out of its way to make sure I don't notice my mistake.
I would like to have a DeleteBehavior option that simply does nothing. If a navigation property of a child entity points to a deleted parent entity, I want SaveChanges to send a DELETE command for the parent and leave the child alone, so that my DB can give me a foreign key constraint exception. Alternatively, EF could also give me an exception on SaveChanges telling me that something points to a deleted entity.
Whether the FK is nullable or not also shouldn't matter, don't null it even if it's nullable.
The text was updated successfully, but these errors were encountered: