Posted on: 7/23/2015 6:27:53 PM | Views : 654

hi,
I'm using the data entity model.  When I update a table, I've been qualifying the fields that I want to update:  table.fieldname = value; etc.
 I saw an example that did not specify each field, but when I tried it, I got a message about there being another
record in the database with the same key - so I couldn't add it.    Do you see something wrong with this ?  Do I need to spell out every field I want to update when I'm updating existing records ? 
var upd = client.Find(id);
client.attach(updatedclient);
entry(updatedclient).State= system.Data.EntityState.Modified;
SaveChanges();

I also saw this :
var original = db.Users.Find(updatedUser.UserId); if (original != null) { db.Entry(original).CurrentValues.SetValues(updatedUser); db.SaveChanges(); } but I also get the same message about key already existing.
...

Go to the complete details ...