Cannot attach an entity with the key that already exists.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 13 Apr 2011 14:19

We are working on this issue (attaching new entities before the SubmitChanges() call), but cannot provide any timeframe at the moment. We will post here when any new information on this is available.

Stuart.Stephens
Posts: 7
Joined: Thu 03 Mar 2011 19:59

Post by Stuart.Stephens » Fri 15 Jul 2011 16:30

I ran into this exact same problem with DevArt blocking the object add when I was trying to follow the guidance here:

http://blogs.msdn.com/b/dinesh.kulkarni ... ached.aspx

Eventually I ran across these posts:

http://www.west-wind.com/weblog/posts/2 ... g-Entities

http://www.west-wind.com/weblog/posts/2 ... s-Followup

The second link describes a method by which three data contexts are required (one for update, two for select) where the "original" and "current" version can be provided to the "update".

In my case, I have an object which is selected, manipulated, and then persisted and is thus disconnected (DataContext1). This is my "current" object. I need to process this object in a web service. With this disconnected "current" I take a DataContext2 and select the "original" and then DataContext3.SomeTable.Attach(currentObj, originalObj) and it is working for me.

Just posting in case anyone else finds this thread and is stuck...

Regards,

Stuart

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 18 Jul 2011 16:09

Thank you for sharing your knowledge.

Post Reply