简体   繁体   English

我可以在实体框架4.3中使用RIA服务吗?

[英]Can I use RIA Services with Entity Framework 4.3?

This is my setup: MVC app A domain model with a data access layer using Enitity Framework Code First Silverlight application (displayed in the MVC App) 这是我的设置:MVC应用程序使用Enitity Framework Code First Silverlight应用程序的数据访问层的域模型(显示在MVC应用程序中)

I'm using RIA Service to make the Silverlight App interact with the DB. 我正在使用RIA Service使Silverlight应用程序与数据库交互。

Ria services only supports entity framework 4.1 as of now. Ria服务目前仅支持实体框架4.1。 Current release is 4.3. 目前的版本是4.3。 Seems to be a waste to not get the new features of EF (like migrations and hopefully enum support in the future) just becouse of the Ria service for the Silverlight app. 由于Silverlight应用程序的Ria服务,似乎是浪费而无法获得EF的新功能(如迁移和希望将来支持enum)。

My question is therefore: 我的问题是:

  1. Is it reasonable to rely on the Ria Service when using EF code first (ie will they always lag behind by so much? Could this be a problem down the road?) 在首先使用EF代码时依赖Ria服务是否合理(即它们总是会落后于这么多吗?这可能会成为一个问题吗?)
  2. Do you have an alternative solution where the Silverlight app is not so dependent on what version of the ORM i use? 您是否有另一种解决方案,Silverlight应用程序不依赖于我使用的ORM版本?

RIA Services can be used with NHibernate or any other ORM or object/domain model. RIA Services可以与NHibernate或任何其他ORM或对象/域模型一起使用。 Only some of the VS Wizards imply there is coupling between EF and RIA Services, but you clearly aren't required to use those wizards nor is there a coupling between EF and RIA Services. 只有一些VS向导意味着EF和RIA服务之间存在耦合,但您显然不需要使用这些向导,也不存在EF和RIA服务之间的耦合。

The answer to the question "Can I use RIA Services with Entity Framework 4.3?" 问题的答案“我可以将RIA服务与实体框架4.3一起使用吗?” is absolutely yes. 绝对是的。

OData is an alternative to RIA Services, but it has quite a few limitations and is not intended as a direct competitor. OData是RIA服务的替代品,但它有很多限制,并不打算作为直接竞争对手。 WCF is also an alternative. WCF也是另一种选择。

A workaround for getting migrations before RIA services properly supports EF4.3 could also be to create a project solely for migrations, similar in spirit to the database projects in Visual Studio Ultimate. 在RIA服务正确支持EF4.3之前获得迁移的解决方法也可以是创建仅用于迁移的项目,与Visual Studio Ultimate中的数据库项目类似。

The model would need to be included by such a project via "add as link" and you'd need to make sure that it can compile in both projects. 这个项目需要通过“添加为链接”来包含该模型,并且您需要确保它可以在两个项目中进行编译。 For example, you might need to define some dummy attribute that are defined in RIA-Services ("Include" would be one). 例如,您可能需要定义一些在RIA-Services中定义的虚拟属性(“包含”将是一个)。

It's not ideal but maybe it's the best option in some cases. 这不是理想的,但在某些情况下可能是最好的选择。

To get a temporary workaround for the lock of version < 4.2 of the RiaServices.EntityFramework NuGet package, I've used the NuGet Package Explorer in order to change the metadata of the package and removed the constraint. 为了获得RiaServices.EntityFramework NuGet包的版本<4.2的锁的临时解决方法,我使用了NuGet包资源管理器来更改包的元数据并删除了约束。

Remeber you must add the local cache as NuGet source . 记住你必须将本地缓存添加为NuGet源

Tools -> Options -> Package Manager -> Package Sources -> Add (C:/Users/%username%/Appdata/Local/Nuget/Cache) 工具 - >选项 - >包管理器 - >包源 - >添加(C:/ Users /%username%/ Appdata / Local / Nuget / Cache)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM