When I try to execute the follwoing code I get the follwoing error.
An object with the same key already exists in the ObjectStateManager. The existing object is in the Modified state. An object can only be added to the ObjectStateManager again if it is in the added state. How can I solve the problem?
for (int i = 0; i < uploadedFiles.Count; i++)
HttpPostedFile userPostedFile = uploadedFiles[i];
if (userPostedFile.ContentLength > 0)
myWorkDocs.Filename = guidResult;
myWorkDocs.UploadedBy = User.Identity.Name;
myWorkDocs.UploadedOn = DateTime.Now;
myEntity2.AddToWorkOrderDocs(myWorkDocs); <-----error here