I have 2 classes (summarized for brevity) :
public class Product : Entity<Guid>
{
...
public virtual IList<Ingredient> Ingredients { get; set; }
public Product(){Ingredients = new List<Ingredient>();}
}
and
public partial class Ingredient : Entity<int>
{
...
public virtual IList<Product> Products { get; set; }
public Ingredient(){Products = new List<Product>();}
}
They have a ManyToMany relationship, and I want to do:
- if I delete one ingredient, the product is not removed but only the ingredient for his list.
- if I delete one product, the ingredients are all without being deleted.
I did this map, but I can't get this to work.
orm.ManyToMany<Product, Ingredient>();
orm.Cascade<Product, Ingredient>(CascadeOn.DeleteOrphans);
Finally, I got it. This is the way I could resolve this, in case to help someone more: