Skip to content
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

DeleteBehavior.ClientSetNull documentation is wrong #9687

Closed
Wain123 opened this issue Sep 4, 2017 · 3 comments
Closed

DeleteBehavior.ClientSetNull documentation is wrong #9687

Wain123 opened this issue Sep 4, 2017 · 3 comments

Comments

@Wain123
Copy link

Wain123 commented Sep 4, 2017

https://docs.microsoft.com/en-us/ef/core/saving/cascade-delete contains the sentence "[...] control whether the deletion of a principal/parent entity should have a side effect on dependent/child entities it is related to."

DeleteBehavior metadata contains the sentence "Indicates how a delete operation is applied to dependent entities in a relationship when the principal is deleted or the relationship is severed."

ClientSetNull sets the FK to null when the navigation property is set to null (i.e. the relationship is severed). It does nothing when the parent is deleted. When SaveChanges is called with a deleted parent, it sets the FK to null.

The docs, metadata and actual behavior are all mutually distinct in describing when exactly a DeleteBehavior does something.

This might apply to other DeleteBehaviors too, I just tested it with ClientSetNull.

@ajcvickers
Copy link
Contributor

@Wain123 Agree the the documentation could be clearer. I think the bit that is missing is when the FK is set to null:

  • When changing a navigation property, the FK will be updated as soon as EF detects the change
  • When deleting an entity, the FK is set to null when the change is cascaded in SaveChanges

@ajcvickers
Copy link
Contributor

Read through after triage and docs don't cover delete orphans behavior.

@ajcvickers
Copy link
Contributor

Filed dotnet/EntityFramework.Docs#473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants