private void FixupMainEntity1(MainEntity1 previousValue) { if (previousValue != null && previousValue.SubEntities.Contains(this)) { previousValue.SubEntities.Remove(this); } if (MainEntity1 != null) { if (!MainEntity1.SubEntities.Contains(this)) { MainEntity1.SubEntities.Add(this); } if (MainEntity1Id != MainEntity1.Id) { MainEntity1Id = MainEntity1.Id; } } }