11

After migrating to EntityFramework and VS 2013, I can't update or delete a ressource.

Request URL:service.svc/Orders(22354)
Request Method:DELETE
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Host:localhost
Origin:http://localhost
Proxy-Connection:keep-alive
Referer:orders.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)         Chrome/31.0.1650.57 Safari/537.36
X-Requested-With:XMLHttpRequest

I have the following error:

   <?xml version="1.0" encoding="UTF-8"?>
   <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
       <m:code />
       <m:message xml:lang="fr-FR">An error occurred while processing this request.</m:message>
       <m:innererror>
           <m:message>Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.</m:message>
           <m:type>System.Resources.MissingManifestResourceException</m:type>
           <m:stacktrace>at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)&#xD;
      at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark&amp; stackMark)&#xD;
      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark&amp; stackMark)&#xD;
      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)&#xD;
      at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)&#xD;
      at System.Data.Services.TextRes.GetString(String name, Object[] args)&#xD;
      at System.Data.Services.Providers.ObjectContextServiceProvider.SetConcurrencyValues(Object resource, Nullable`1 checkForEquality, IEnumerable`1 concurrencyValues)&#xD;
      at System.Data.Services.UpdatableWrapper.SetETagValues(Object resourceCookie, ResourceSetWrapper container)&#xD;
      at System.Data.Services.DataService`1.HandleDeleteOperation(RequestDescription description, IDataService dataService)&#xD;
      at System.Data.Services.DataService`1.ProcessIncomingRequest(RequestDescription description, IDataService dataService)&#xD;
      at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)&#xD;
      at System.Data.Services.DataService`1.HandleRequest()</m:stacktrace>
       </m:innererror>
   </m:error>

Any idea ?

Thanks for your help.

nboukeffa
  • 127
  • 1
  • 9
  • 1
    Looks like after the update your resource file miss the configuration, look at this specific resource and see if Its config as Embedded. – Fals Dec 02 '13 at 15:59
  • The only ressource files I use in the project are those for globalization and they are config as Embedded. Any way to find which ressource file causes the problem ? Thanks! – nboukeffa Dec 03 '13 at 10:34
  • 3
    The ressource error seems to be a second error which is throwed by the EntityFrameworkProvider when it try to find the ressource file to translate the first error message... I think the first error is caused by System.Data.Services.Providers.ObjectContextServiceProvider.SetConcurrencyValues but I don't know why. When I delete the navigation properties in my Order class, I don't have the error anymore. – nboukeffa Dec 05 '13 at 09:34
  • 1
    Upvoted this question since I'm getting the same problem. See comments at http://blogs.msdn.com/b/astoriateam/archive/2013/10/02/using-wcf-data-services-5-6-0-with-entity-framework-6.aspx for others experiencing this or similar issues. Note that I do not have Enums in my model, which is one reported cause. – Dave A-W Jan 06 '14 at 04:05
  • 1
    Same problem here, and no enums either. It sounds like when any data services error is happening (in my case it could be a model error when saving certain entities) there is an error while trying to fetch the error message out of the resources file (which doesn't exist or wasn't compiled into EntityFrameworkProvider). I don't see any resource files for System.Data.Services.resources, but I am seeing Microsoft.Data.Services.resources in one of the packages, could it be that those will work? I'll post back here if I decide to try it.. – vbigham Jan 10 '14 at 18:49
  • In the same boat as Nad1. I've tried removing the Enums from the exposed context and the edmx, and ensured I wasn't attaching a new object to the client context as Sergej describes below. Pretty frustrated trying to get EF 6.02 working with WCF Data Services 5.6.0 – Will Rogers Feb 06 '14 at 17:05
  • 1
    This happens in the provider while looking for ETags. It appears `System.Data.Services.UpdatableWrapper()` calls a `IConcurrencyProvider` implemented in Microsoft.OData.EntityFrameworkProvider.dll. (I cannot find any PDB symbols for Microsoft.OData.EntityFrameworkProvider.dll on SymbolSource or any other symbol host) My gut reaction after looking in the `UpdatableWrapper()` method is that since bool? checkForEquality is initialized as null that the `IConcurrencyProvider` implementation in Microsoft.OData.EntityFrameworkProvider.ddl may not be properly handling a null checkForEquality value. – Adam Caviness Mar 06 '14 at 18:42

3 Answers3

1

In case someone want to try this solution ... I had same problem. It seems that this error come up if i attach a detached entity to a context an then try to update/delete it.

Entity entity; //detached

context.AttachTo("entitySetName", entity);
context.DeleteObject(entity);
context.SaveChanges(); //exception

This has worked for me.

//get entity from context instead of attaching the "old" one
var newEntity = ctx.Table.Where(w => w.ID == Entity.ID).FirstOrDefault();

context.DeleteObject(newEntity);
context.SaveChanges(); //works
0

In our case, having the client set SaveChangesOptions.Batch was throwing this exception. Setting it to SaveChangesOptions.BatchWithIndependentOperations did not throw, but we can't use BatchWithIndependentOperations in our scenario. Hopefully this will save someone else wasted time.

Adam Caviness
  • 3,424
  • 33
  • 37
0

For those of you not using the Microsoft OData client, I got this problem to go away by forcing my client to use MERGE requests for updates rather than PUT ones.

Reid Rankin
  • 1,078
  • 8
  • 26