Searching about the cascading behavior of Entity Framework
, if noticed this answer. On short, the OP is searching for a way to perform cascade delete on 1-0 / 1-1 relationships in Entity Framework
, and the best answer contains a snippet on Fluent API applying WillCascadeOnDelete(true);
On the DB Context's modelBuilder.
On the selected answer, a user (CodeMonkey) mentioned:
(...) Some have suggested [Required] for cascading delete. This indeed works, but of course, only if it is actually required
My question is, if the relation is set to 1-1 (using [Required] or even without setting the relation as optional to EntityTypeConfiguration
) with required dependencies, is cascade delete performed by default, without having to set it to Fluent API, as mentioned on the comment?
Code First Conventions