1
Vote

Handling of Primary keys on database inserts

description

When you have an identity field as your primary key, it seems that you have to use the Insert() Extension method, in order to return and set the primary key on your new object.


Example: acc.AccountID = db.Accounts.Insert(acc, PK => PK.AccountID);


My questions are:
1) How do you update your object, if you have a table/entity with multiple primary key columns?
2) If you use the EntitySession, it seems that you cannot use a selector for inserts(), hence, you do not get the primary keys returned from the inserts made by the SubmitChanges() method.


Is the above, some features missing from the Toolkit, or am I approaching databse inserts the wrong way?

Regards,
Michael

comments