Loading

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
posted @ 2019-04-17 14:31  wswind  阅读(374)  评论(0编辑  收藏  举报