C# · 12月 30, 2021

c# – 在WCF数据服务应用程序中迁移EntityFramwork 6和VS 2013后无法更新或删除

@H_419_1@迁移到EntityFramework和VS 2013之后,我无法更新或删除资源. Request URL:service.svc/Orders(22354)Request Method:DELETEStatus Code:500 Internal Server ErrorRequest Headersview sourceAccept:application/json,text/javascript,*/*; q=0.01Accept-Encoding:gzip,deflate,sdchAccept-Language:en-US,en;q=0.8,fr;q=0.6Host:localhostOrigin:http://localhostProxy-Connection:keep-aliveReferer:orders.htmlUser-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/31.0.1650.57 Safari/537.36X-Requested-With:XMLHttpRequest

我有以下错误:

<?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) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture,Dictionary`2 localResourceSets,Boolean tryParents,Boolean createIfNotExists,StackCrawlMark&amp; stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture,StackCrawlMark&amp; stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture,Boolean tryParents) at System.Resources.ResourceManager.GetString(String name,CultureInfo culture) at System.Data.Services.TextRes.GetString(String name,Object[] args) at System.Data.Services.Providers.ObjectContextServiceProvider.SetConcurrencyValues(Object resource,Nullable`1 checkForEquality,IEnumerable`1 concurrencyValues) at System.Data.Services.UpdatableWrapper.SetETagValues(Object resourceCookie,ResourceSetWrapper container) at System.Data.Services.DataService`1.HandleDeleteOperation(RequestDescription description,IDataService dataService) at System.Data.Services.DataService`1.ProcessIncomingRequest(RequestDescription description,IDataService dataService) at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description) at System.Data.Services.DataService`1.HandleRequest()</m:stacktrace> </m:innererror> </m:error>

任何想法 ?

谢谢你的帮助.

解决方法 如果有人想尝试这个解决方案…我有同样的问题.如果我将一个分离的实体附加到上下文然后尝试更新/删除它,似乎这个错误出现了. Entity entity; //detachedcontext.AttachTo(“entitySetName”,entity);context.DeleteObject(entity);context.SaveChanges(); //exception

这对我来说是有效的.

//get entity from context instead of attaching the “old” onevar newEntity = ctx.Table.Where(w => w.ID == Entity.ID).FirstOrDefault();context.DeleteObject(newEntity);context.SaveChanges(); //works