User-1330468790 posted
Hi amithashenoy,
I think what you mean is "Cascade Delete". A closely related concept also covered by EF Core delete behaviors is the automatic deletion of a child entity
when it's relationship to a parent has been severed--this is commonly known as "deleting orphans".
From documents, it is saying that:
There are several delete behaviors defined in the DeleteBehavior enumerator type, which can be passed to the OnDelete fluent API to control whether the deletion of a principal/parent entity or the severing of the relationship to dependent/child
entities should have a side effect on the dependent/child entities.
There are three actions EF can take when a principal/parent entity is deleted or the relationship to the child is severed:
- The child/dependent can be deleted
- The child's foreign key values can be set to null
- The child remains unchanged
In short, for optional relationships (the FK can be null), the default behavior is "ClientSetNull", which will set the FK property to null in memory but do nothing for database.
Hope this can help you.
Best regards,
Sean