efcore 级联删除

https://docs.microsoft.com/en-us/ef/core/saving/cascade-delete#required-relationships

Optional relationships

For optional relationships (nullable foreign key) it is possible to save a null foreign key value, which results in the following effects:

Behavior NameEffect on dependent/child in memoryEffect on dependent/child in database
Cascade Entities are deleted Entities are deleted
ClientSetNull (Default) Foreign key properties are set to null None
SetNull Foreign key properties are set to null Foreign key properties are set to null
Restrict None None

Required relationships

For required relationships (non-nullable foreign key) it is not possible to save a null foreign key value, which results in the following effects:

Behavior NameEffect on dependent/child in memoryEffect on dependent/child in database
Cascade (Default) Entities are deleted Entities are deleted
ClientSetNull SaveChanges throws None
SetNull SaveChanges throws SaveChanges throws
Restrict None None
原文地址:https://www.cnblogs.com/wswind/p/10723359.html