简体   繁体   中英

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)

I'm using RIA Service to make the Silverlight App interact with the DB.

Ria services only supports entity framework 4.1 as of now. Current release is 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.

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?)
  2. Do you have an alternative solution where the Silverlight app is not so dependent on what version of the ORM i use?

RIA Services can be used with NHibernate or any other ORM or object/domain model. 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.

The answer to the question "Can I use RIA Services with Entity Framework 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. WCF is also an alternative.

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.

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).

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.

Remeber you must add the local cache as NuGet source .

Tools -> Options -> Package Manager -> Package Sources -> Add (C:/Users/%username%/Appdata/Local/Nuget/Cache)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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