1

Closed

Changing namespaces breaks WCF data services server

description

If I upgrade a working solution using WCF data services 5.3.0 and EF 5.0 to use EF 6.0 alpha 2, I get this error:
<p>The server encountered an error processing the request. The exception message is 'Expression of type 'System.Data.Entity.Core.Objects.ObjectContext' cannot be used for return type 'System.Data.Objects.ObjectContext''. See server logs for more details. The exception stack trace is: </p>
      <p>   at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression&amp; 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&amp; metadataProviderInstance, IDataServiceQueryProvider&amp; queryProviderInstance, BaseServiceProvider&amp; builtInProvider, Object&amp; dataSourceInstance)
   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[]&amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
This occurs because the namespace of ObjectContext has changed.
Closed Feb 28, 2013 at 10:58 PM by RoMiller
EF Team Triage: We are following up with the WCF Data Services team about adding support for EF6. We can't speak for other teams but we certainly pay attention to votes on UserVoice. We're going to close this issue since it's not something that we need to fix in EF.

comments

moozzyk wrote Feb 22, 2013 at 4:40 PM

The reason for this is that the EF6 DbContext and ObjectContext are from the CLR point of view totally different types (even though they happen to have the same names) than the ones from EF5 and WCF Data Services does not recognize them. The change to support new types needs to be done on the WCF Data Services side. Another option would be to implement WCF Data Services Provider for EF6. It is not trivial though...

johncrim wrote Feb 22, 2013 at 5:36 PM

Thanks moozzyk - that makes sense. I considered writing a custom WCF data services provider, but that would blow up the scope of my implementation, so it was easier to roll back to EF 5.

I submitted this case both to flag the issue, and because there's no place for me to submit bugs to the WCF data services team (afaict - I'm assuming UserVoice is more of a black hole).

RoMiller wrote Feb 28, 2013 at 10:57 PM

EF Team Triage: We are following up with the WCF Data Services team about adding support for EF6. We can't speak for other teams but we certainly pay attention to votes on UserVoice. We're going to close this issue since it's not something that we need to fix in EF.