The property 'Id' is part of the object's key information and cannot be modified

后端 未结 15 2297
天涯浪人
天涯浪人 2020-11-27 07:02

i\'m using Entity Framework 4.0 and having a silly problem that i can\'t figure out.

I have two tables:

  1. Contact: Id (primary key), Value, ContactTypeId
15条回答
  •  粉色の甜心
    2020-11-27 07:37

    In my case, I want to duplicate the object, but change the id, so I use this

    Common.DataContext.Detach(object);
    

    Work like a charm

提交回复
热议问题