views:

108

answers:

1

I have a Silverlight application and I'm using a WCF service to access my database information. For this I'm using EntityFramework. I have a class Items (mapped on my DB table Items) which has an ObservableCollection of Keywords (class mapped on my DB table Keywords) objects.

From the interface I create an Items object with all the properties set including the Keywords list (if the keyword already exists I add the object retrieved by EntityFramework and if a keyword doesn't exist I create from the interface a new Keywords object and add it to my ObservableCollection of my Item). When I pass the Item object to the service and try to add it to the DB, I get the following error: An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.

How can I solve this problem?

A: 

Looks like the context already contains your object. ... check if Attach works instead of add...

silverfighter