I have a configuration like this in my codes:
builder.HasMany(c => c.Libs)
.WithOne(x=>x.Book)
.HasForeignKey(x=>x.BookId)
.OnDelete(DeleteBehavior.NoAction); <<-------- Here
My question is what is different between NoAction
and Restrict
value?
I read Microsoft document and descriptions of both of them are same!!!
DeleteBehavior.Cascade – Delete the child when the parent is deleted (e.g. Cascading deletes) DeleteBehavior.SetNull – Set the FK on the child to just be null (So allow orphans) DeleteBehavior.Restrict – Don't allow the parent to be deleted at all.
WillCascadeOnDelete(Boolean) Configures whether or not cascade delete is on for the relationship. C# Copy.
It depends on the database implementation.
In T-SQL and MySQL, there is no difference.
In PostgreSQL, there is a difference: Difference between RESTRICT and NO ACTION
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With