Cascading Deletion is a relationship configuration, not an entity / table. Therefore, WillCascadeOnDelete
is a CascadableNavigationPropertyConfiguration
method. Example usage example:
modelBuilder.Entity<Review>() .HasRequired(r => r.Wine) .WithMany() .WillCascadeOnDelete(false);
This means that if wine is removed from the catalog in the database, its reviews should not be deleted along with the wine. This is a property of this particular relationship, not the Reviews
table.
In this case, an attempt to delete a wine that has reviews will violate the foreign key constraint and an exception, of course, but this is what you usually want when you turn off cascading deletion for the desired relationship ("Do not allow deleting wine that has reviews, allow it only to wines that do not have ... ").
source share