c# - updaing\saving with EF violates a DB uniquness restriction -


i'm using ef update entity.

here code:

    public mamconfiguration_v1 save(mamconfiguration_v1 item)     {             item.throwifnull("item");              mmamdbentities.mamconfiguration_v1.addobject(item);              mmamdbentities.objectstatemanager.changeobjectstate(item, system.data.entitystate.modified);              mmamdbentities.savechanges();              return item;     } 

however in way pk violation erorr in db.

i prefer use way (creating new ef entity) , marking

modified, how can not break uniquness restriction?

if using method update existing item, receive exception because of

  mmamdbentities.mamconfiguration_v1.addobject(item); 

line. looks code trying put item table second time. if guessed right , use method update existing items, should remove line - ef automatically update db according changes made object's fields.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -