Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Entity Framework what is the difference between Cascade and ClientCascade?

I am learning C# and how to use Entity Framework. I believe that I know what is Cascade, Restrict, NoAction and SetNull behaviors.

But there are other behaviors with the prefix Client:

enter image description here

I would like to understand what are the difference between them and when should I use ClientCascade instead of Cascade or ClientNoAction instead of NoAction.

like image 504
The Apprentice Avatar asked May 22 '26 02:05

The Apprentice


1 Answers

the short answer is-- when dependent/ref. entities are loaded/cached in memory, the cascade delete action fails on the main entity - because a CYCLIC ref. LOCK.

ClientCascade allows the DBContext to delete entities even if there is a CYCLIC ref. LOCK

EF Core Cascades vs. Client Cascades Delete

like image 186
Transformer Avatar answered May 23 '26 14:05

Transformer