Updating primary key columns is not a good practice. it confuses ef because it changes the identity of the object, and makes keeping the in-memory copy and the in-database copy of the data in sync very problematic.. As a result of being part of the entity key the object needs to be deleted from the context and re-attached with the new primary key value. the entity framework works by having a context which manages the state of the entities, a collection of entities (basically the table) and the entity itself (a row of data).. Update accounts set account_id = '30' where account_id = '20' and user_id = '10'; while the above works for situations where you retain all values of your composite key, i'm all for an immutable key behind the scenes that is never shared or displayed..
If you have defined the foreign key constraints as on update cascade then the primary key value that was changed should cascade down to all the foreign keys with that constraint. if you do not have the on update cascade constraint, then you will need create scripts to complete the update.. A composite primary key is a primary key defined by more than one attribute. if you run this code on a sql server you will see a empty table called silly_teacher_table. if you use a gui like sql server managment studio, you can examine the properties of the table and see that the teachid and courseprefix id both have a key.. Converting a composite primary key to composite unique, and adding an auto-incremented pk column 0 sql server partitioned view wrong execution plan on update a temporary table.