3

Model:

public class MenuItem { public Guid Id {get;set;} public virtual Guid? ParentMenuItemId {get;set;} public virtual MenuItem ParentMenuItem {get;set;} public virtual ICollection<MenuItem> ChildMenuItems {get;set;} } 

current mapping:

HasOptional(m => m.ParentMenuItem).WithMany(p => p.ChildMenuItems).HasForeignKey(m => m.ParentMenuItemId); 

I tried adding the WillCascadeOnDelete(true), but I got an error. How should I update my mapping to allow for cascading deletes? So, If I delete a Parent, all the children will be deleted. Do I have to do this manually?

1
  • What error are you receiving? Commented Feb 24, 2012 at 16:20

1 Answer 1

2

In your model, just look at the association's properties. There is an OnDelete that you can set to Cascade. The XML should look like this:

<OnDelete Action="Cascade" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.