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 Name Effect on dependent/child in memory Effect 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 Name Effect on dependent/child in memory Effect 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
上一篇:linux删除文件后没有释放空间


下一篇:HTML CSS——position学习终结者(二)