刚刚升级了一个 .NET 4.5 WCF 服务,它也有一个 OData 服务来使用 EF 6。OData 服务在升级之前当然可以工作。现在,当尝试查询 OData 服务甚至只是从 Visual Studio 2012 浏览到它时,我收到以下请求错误:
服务器在处理请求时遇到错误。异常消息是“'System.Data.Entity.Core.Objects.ObjectContext' 类型的表达式不能用于返回类型'System.Data.Objects.ObjectContext'”。有关更多详细信息,请参阅服务器日志。
异常堆栈跟踪是:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable`1 parameters)
at System.Data.Services.Providers.DbContextHelper.CreateDbContextAccessor(Type type)
at System.Data.Services.Providers.DbContextHelper.GetDbContextAccessor(Type type)
at System.Data.Services.DataService`1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, Object& dataSourceInstance, Boolean& isInternallyCreatedProvider)
at System.Data.Services.DataService`1.CreateProvider()
at System.Data.Services.DataService`1.HandleRequest()
at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
ODataLib 是 5.6,EF 是 6.0.1,WCF 数据服务服务器是 5.6。
这个问题没有帮助。我也从这里完成了所有事情,但没有运气。我没有提及System.Data.Entity
. 我能做些什么来克服这个问题?