My understanding is that, using Fluent API, this code:
modelBuilder.Entity<Parent>()
.HasOptional(p => p.Child)
.WithOptionalPrincipal(c => c.Parent)
.Map(m => m.MapKey("ParentId"))
.WillCascadeOnDelete(true);
..should cause Child to be deleted whenever the linked Parent is deleted. However, I can't get this to work.
Whenever I delete a Parent, the ParentId field of the corresponding Child is simply set to null instead of deleting the child.
I checked this question, but the answer there is confusing to me because it seems to make the parent the Dependent side, and it didn't actually work for me anyway.
What am I doing wrong?