I have a (simplified) entity model as follows
public class Address {
}
public class PersonAddress {
public Address Address {get; set;}
}
public class Person {
ICollection<PersonAddress> Addresses { get; set;}
public void SetAddresses(params Address addresses[]) {
Addresses.Clear();
addresses.Select(a => new PersonAddress(this, a)).ForEach(Addresses.Add);
}
}
This is implemented as a join-class on purpose as it actually makes more sense in my business model than a many-to-many.
Understandably, when SetAddresses
is executed what happens in the database is that the PERSON_ADDRESS.FK_PERSON_ID
reference in the now removed PERSON_ADDRESS
record gets nulled out. What I want however is for it to be deleted entirely.
Edit: From the comments below I understand that what I want is maybe for PersonAddress
to have an "Identifying Relationship" from Person
but how do I configure this given the above model using the fluent api?