-
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
Restrict behaves like ClientSetNull in EF Core 2.2 Npgsql #16588
Comments
@ArthDevRepo The issue here is that the documentation is incorrect. |
I want to change de navigation property without setting fk to null, any chance to do it? |
Restrict
|
@ArthDevRepo Can you explain why you want to do that? |
Remove the post from blog posts list. Or set post.blog navigation property to NULL. |
@ArthDevRepo But why do you want to do that? (As I said, the documentation here is wrong.) |
I know that doing this does not make sense since I'm deleting the relationship explicitly. My question was whether I was doing it the right way, since the documentation said that FK was not changed. Testing again, I noticed that when deleting the relationship (remove the post from blogs post list), configured with DeleteBehaivor.Cascade, the FK is not changed as with ClientSetNull, SetNull and Restrict. Is that correct? thank you! |
@ArthDevRepo Whether or not an FK is set to null depends on whether or not the relationship is required or not, in addition to the delete behavior. A required relationship implies the FK is non-nullable, and hence cannot be set to null. |
When a relationship is severed, the fk is set to null if cascade behaivor is clientsetnull, setnull and restrict. Cascade never touch the fk |
I'm using EF Core 2.2 and when i set Delete Behaivor in a relationship to Restrict, the foreign key is set to null in tracked entities when they are made orphans. This is not in accordance with the behavior described in this article: do not set foreign key property in the child entity to null.
Article: https://docs.microsoft.com/pt-br/ef/core/saving/cascade-delete#feedback
Source code in:
https://github.com/ArthDevRepo/EfCoreRestrictBehaivorProblem
Expected behaivor: When Restrict, do not set FK Property to NULL
Actual behaivor: When Restrict, set FK Property to NULL.
The text was updated successfully, but these errors were encountered: