You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when setting DeleteBehavior.Cascade or SetNull, EF Core generates cascading statements for any tracked dependents. This isn't harmful, but is unnecessary since the behavior is already performed by the database.
The text was updated successfully, but these errors were encountered:
roji
changed the title
Stop generated cascade delete updates when the DeleteBehavior is database-side
Stop generated cascade delete statements when the DeleteBehavior is database-side
Jul 5, 2020
And 1 option with a well-known name but a different meaning that does not mimic the behavior of the server:
ClientNoAction - the client does nothing with children
1. There should be a ClientRestrict option for completeness - client checks whether any child entity is loaded and whether it is in a deleted / detached state, and throws an exception if necessary
2. Can ClientDetach be usable? For example if we want to do something with child entities after saving changes.
Then we can get the following:
[Server]Cascade - server deletes children, client has default behavior
ClientCascade - client changes the states of the loaded children and generates SQL for these changes, server has default behavior
[Server]Cascade | ClientCascade - both server and client delete [loaded] children (this is current Cascade behavior)
[Server]Cascade | ClientNoAction - server deletes children, client does nothing (good for performance but inconsistent on client side)
[Server]Cascade | ClientDetach - server deletes children, client detaches loaded children from context (still better than current Cascade for performance and semi-consistent on client side)
[Server]Cascade | ClientRestrict - server deletes children, but client checks whether any child entity is loaded and is not in the delete/detach state and throws an exception if necessary before saving changes (still better than current Cascade for performance and good for consistency)
etc...
For me, this is much more flexible and convenient than current implementation.
Currently, when setting DeleteBehavior.Cascade or SetNull, EF Core generates cascading statements for any tracked dependents. This isn't harmful, but is unnecessary since the behavior is already performed by the database.
The text was updated successfully, but these errors were encountered: