Fluent many-to-many: Deleting one end does not remove the entry in the relation table
- by Kristoffer
I have two classes (Parent, Child) that have a many-to-many relationship that only one end (Parent) knows about. My problem is that when I delete a "relation unaware" object (Child), the record in the many-to-many table is left.
I want the relationship to be removed regardless of which end of it is deleted. How can I do that with Fluent NHibernate mappings, without adding a Parent property on Child?
The classes:
public class Parent
{
public Guid Id { get; set; }
public IList<Child> Children { get; set; }
}
public class Child
{
public Guid Id { get; set; }
// Don't want the property below:
// public Parent Parent { get; set; }
}