I have Customer, CustomerGroups, Groups tables. Customer has 1:n with CustomerGroups and Groups has 1:n with CustomerGroups. In the create customer screen, user can choose the groups information of existing customer. So when I create a new customer, I am retrieving groups from existing customer and adding them
///
Customer cust = new Customer();
foreach(var item in getothercustomergroups())
cust.groups.add(item);
commit
This code is generating update statement and updating the customergroups table with newly added customerid, instead of inserting new records with new customerid. Due to this, all groups with prev. customer are gone. Could anyone please explain this behavior.