I have an ADO.Net data service that I use to import data. There are a number of objects that are associated with most objects. To do this, during import, I first create these objects, save them, and then use .SetLink (EntityImport, "NavigationProperty", CreatedEntity). Now the first problem I ran into was that the context did not always know about CreateEntity (this is due to the fact that each of the entities imported independently, and creating a context when creating each element - I would like to keep this functionality - t .e. I try to avoid "just use one context" as an answer).
So, before trying to call SetLink, I have .AddToCreatedEntityType (CreatedEntity). This, of course, works for the first time, but in the second pass I get the error "the context is already tracking the entity."
Is there a way to check if the context is already tracking the object (context.Contains (CreatedEntity) has not yet been implemented)? I was thinking of trying to catch a try and just avoid the error, but this seems to create a new CreateEntity every pass. It seems like I need to use LINQ to Data Services to get this CreateEntity every time, but it seems inefficient - any suggestions?
source
share