2

I've got stuck while updating data in my db, so maybe you can help me.

I have a DataContext with 3 EntitySets based on this dependency flow ( A -> B -> C ).

When my program executes, 4 entities are created ( one for entity set A, two for entity set B and one for entity set C).

I add these newly created entities using : context_name.Entity_set_name.Add(Entity_name). For example :

context.A.Add(AEntity);
context.B.Add(BEntity1);
context.B.Add(BEntity2);   // gives error
context.C.Add(CEntity);

The program gives "The specified entity is already contained in an EntitySet" while executing the BEntity2 add. Note that the two entities (BEntity1 and BEntity2) do not contain the same dataset.

Tzoma
  • 43
  • 1
  • 6
  • 1
    Check the references of the entity objects. May be the names are different but somewhere it may refer the same dateset. – Thanushka Apr 11 '13 at 12:43
  • I've doublechecked them ... every field value is different. It works fine however when i comment one of two B EntitySet adds (line 2 or 3). Still no solution found yet ... – Tzoma Apr 11 '13 at 13:30
  • @Tzoma Did You find solution? I have similar problem and I don't know why. – Jacek Gzel Mar 28 '17 at 12:53
  • Hi Jacek, i don't recall ... happened 4years ago ... but it'd be nice if somebody posted a solution. Not working in c# anymore, so i can't help out ... :( – Tzoma Mar 29 '17 at 16:24

0 Answers0