使用WCF数据服务5.6.0与实体框架6+ [英] Using WCF Data Services 5.6.0 with Entity Framework 6+

查看:367
本文介绍了使用WCF数据服务5.6.0与实体框架6+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让我们的WCF数据服务与新的实体框架6一起使用。

I have been trying to get our WCF Data Service to work with the new Entity Framework 6.

我发现这个 article 这解释了解决这个问题的简单和无痛的方法。

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

我收到错误:


错误16类型
'Microsoft.OData.Service.DataService`1'在未引用的程序集
中定义。您必须添加对程序集
'Microsoft.OData.Service,Version = 5.6.0.0,Culture = neutral,
PublicKeyToken = 31bf3856ad364e35'的引用。 C:\Realtime Source\RTR
6.x\RTRServices\RTRWCFDataService\RTRWCFDataService\RTRWCFData.svc.cs 21 16 RTRWCFDataService

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=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\Realtime Source\RTR 6.x\RTRServices\RTRWCFDataService\RTRWCFDataService\RTRWCFData.svc.cs 21 16 RTRWCFDataService

在研究似乎解决方案是升级到alpha 2 ...并使用命令:

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:


异常使用8参数调用CreateInstanceFrom:可以
不加载类型
'System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand'
from assembly'E ntityFramework.PowerShell,Version = 5.0.0.0,
Culture = neutral,PublicKeyToken = b77a5c561934e089' 。在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异常调用CreateInstanceFrom与8参数:无法加载
类型系统.Data.Entity.ConnectionFactoryConfig.AddProviderCommand'
from assembly'EntityFramework .PowerShell,Version = 5.0.0.0,
Culture = neutral,PublicKeyToken = b77a5c561934e089'。在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.InitializeEntityFrameworkCommand' from assembly 'E ntityFramework.PowerShell, Version=5.0.0.0, 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=5.0.0.0, 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

然后,我失去了访问 Microsoft.ODATA 命名空间的能力...基本上让我从我需要的类中nish升级 Microsoft.OData.Service.Providers.EntityFrameworkDataService

Then I lose the ability to access the Microsoft.OData namespace... basically keeping me from the class that I need to finish the upgrade Microsoft.OData.Service.Providers.EntityFrameworkDataService

在这个问题上,任何帮助都会很大感谢!

Any help at all on this issue would be greatly appreciated!

推荐答案

虽然我能够安装Alpha 2版本,但我遇到了这个提供者的很多问题。其中许多产生不清楚或误导的例外,正如您可以在原始公告的评论中找到的。而目前,开发商并没有积极参与社区的工作。事实上,鉴于自从Alpha Alpha发布以来已经过去了将近两个月,所以目前还不清楚这是否是微软的优先事项。

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.

鉴于此,我不会建议在此提供商上生成任何生产代码。事实上,我会犹豫甚至反对它,希望一个更稳定的版本会稍后释放,直到我们看到更多的动力背后这个版本的图书馆。我的怀疑是,随着ASP.NET Web API 2.0的发布,WCF数据服务已经放在后面。

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:

  • Falling back to Entity Framework 5.0.
  • Building a custom Web API w/ OData extensions.
  • Adopting Microsoft's new RESTier.
  • Using an alternate service layer, such as Breeze*.

这可能不是您希望的答案,也不会解决您的直接障碍,但直到有更多运动在官方提供商我会考虑这些选项。

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.

* Breeze是一个客户端JavaScript l ibrary用于消费oData服务,但它还包括一个服务器端库,用于与流行的O / RM进行接口,包括Entity Framework 6.0以及NHibernate。

* Breeze is a client JavaScript library for consuming oData services, but it also includes a server-side library for interfacing with popular O/RMs, including Entity Framework 6.0 as well as NHibernate.

这篇关于使用WCF数据服务5.6.0与实体框架6+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆