I have been trying to get our WCF Data Service to work with the new Entity Framework 6.
I found this article which explains a supposedly easy and painless way to fix this issue.
I followed the directions posted exactly. When I first install:
Install-Package Microsoft.OData.EntityFrameworkProvider -Version 1.0.0-alpha1 -Pre
I get the error:
Error 16 The type 'Microsoft.OData.Service.DataService`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\Realtime Source\RTR 6.x\RTRServices\RTRWCFDataService\RTRWCFDataService\RTRWCFData.svc.cs 21 16 RTRWCFDataService
Upon researching that it seems that the solution is to upgrade to alpha 2... and to do this use the command:
Install-Package Microsoft.OData.EntityFrameworkProvider -Pre
When I use this command the Package Manager Console spits out two errors:
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load type 'System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand' from assembly 'E ntityFramework.PowerShell, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089'." At C:\Realtime Source\RTR 6.x\RTRServices\RTRWCFDataService\packages\EntityFramework.6.0.1\tools\EntityFramework.psm1:698 char:31 + $domain.CreateInstanceFrom <<<< ( + CategoryInfo : NotSpecified: (:) , MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load type 'System.Data.Entity.ConnectionFactoryConfig.AddProviderCommand' from assembly 'EntityFramework .PowerShell, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089'." At C:\Realtime Source\RTR 6.x\RTRServices\RTRWCFDataService\packages\EntityFramework.6.0.1\tools\EntityFramework.psm1:698 char:31 + $domain.CreateInstanceFrom <<<< ( + CategoryInfo : NotSpecified: (:) , MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Then I lose the ability to access the
Microsoft.OData namespace... basically keeping me from the class that I need to finish the upgrade
Any help at all on this issue would be greatly appreciated!
While I was able to install the Alpha 2 release, I've run into quite a few issues with this provider. Many of them yield unclear or misleading exceptions, as you can find in the comments of the original announcement. And, currently, the developers aren't actively engaging the community in working through the issues. In fact, given that nearly two months have passed since the last Alpha release, it's unclear whether or not this is a priority within Microsoft.
Given this, I wouldn't recommend basing any production code on this provider. In fact, I'd be hesitant to even develop against it with the hope that a more stable version will release later until we've seen more momentum behind this version of the library. My suspicion is that with the release of ASP.NET Web API 2.0, WCF Data Services has been put on the back burner.
Until then, you're probably better off pursuing one of the following options:
This probably isn't the answer you're hoping for, nor does it address your immediate hurdle, but until there's more movement on the official provider I'd consider these options instead.
About the issue you met when "Install-Package Microsoft.OData.EntityFrameworkProvider -Pre"
From the error info, it seems that EntityFramework.psm1 of version 6.0.0 is trying to load some code from EntityFramework.PowerShell.dll, Version=126.96.36.199. I tried on my solution, I cannot repro this issue.
So my guess is that you mixed EntityFramework 5.0.0 and EntityFramework 6.0.1 somehow, but actually I don't know how. So my suggestion is to do following steps:
If the first three steps cannot be finished correctly on your project, just manually delete all the EntityFramework folders and Microsoft.OData.EntityFrameworkProvider.1.0.0-alpha2 folder in packages. And then do the fourth step
Hope it works for you