I have 2 classes that have a many to many relationship. What i'd like to happen is that whenever i delete one side ONLY the association records will be deleted with no concern which side i delete.
simplified model:
classes:
class Qualification
{
IList<ProfessionalListing> ProfessionalListings
}
class ProfessionalListing
{
IList<Qualification> Qualifications
void AddQualification(Qualification qualification)
{
Qualifications.Add(qualification);
qualification.ProfessionalListings.Add(this);
}
}
fluent automapping with overrides:
void Override(AutoMapping<Qualification> mapping)
{
mapping.HasManyToMany(x => x.ProfessionalListings).Inverse();
}
void Override(AutoMapping<ProfessionalListing> mapping)
{
mapping.HasManyToMany(x => x.Qualifications).Not.LazyLoad();
}
I'm trying various combinations of cascade and inverse settings but can never get there. If i have no cascades and no inverse i get duplicated entities in my collections. Setting inverse on one side makes the duplication go away but when i try to delete a qualification i get a 'deleted object would be re-saved by cascade'.
How do i do this?
Should i be responsible for clearing the associations of each object i delete?