4

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 (i.e. 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?
Eric Andres
  • 3,417
  • 2
  • 24
  • 40
cfs
  • 1,304
  • 12
  • 30
  • What about just using a WCF abstraction layer? If you pick ria services you are going to try your hands. – O.O Feb 15 '12 at 23:54
  • That's what I fear. What seems to be a quick and simple solution in the start can cause major pain later on. I use SL for showing/creating reports and use I use the Telerik RAD controls for functions that I need to implement but does not need to be accessed by others than admins => spend as little time on them as possible, but still efficient to use. RIA allows me to pretty much just scaffold the methods, and go and bind it to a control in a SL view. Would it be possible to do the same with WCF? Would you publish the WCF on IIS? – cfs Feb 16 '12 at 00:11
  • 1
    The way I see it, RIA is the quick/dirty small app convenient way of building a silverlight application. Reminds me of drag and dropping datasets from the designer. You might look into WCF Data Services or http://stackoverflow.com/questions/2523629/ria-services-versus-wcf-services-what-is-a-difference – O.O Feb 16 '12 at 00:27

3 Answers3

4

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.

Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
  • 1
    Hi, thank you for the response. I must have gotten something wrong, but this sounds like good news. If I use NuGet package installer in VS2010 it wont allow me to install RiaServices.Entityframework becouse it says EF version < 4.2. Do you know anyway around that? Do you know any resource that shows how to implement Ria Services. Bear in mind that i use EF Code First so there has not been any wisards for that as I've seen, only if I map the database and create a new context model from DB i get a wisard, but that solution is not very sound. – cfs Feb 16 '12 at 13:11
  • 4
    You've each identified one of the limitations. First, the 'Add New -> DomainService' Wizard does not work correctly with EF4.3. Second, the NuGet package for RIA.EF has a hard lock on version 4.1. For now, you can get around the NuGet lock using the RIA Toolkit installer (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26939). At that point, you should be able to upgrade to EF4.3 just fine. Also, I'd expect to see the NuGet constraint resolved in the near future. – Kyle McClellan Feb 16 '12 at 17:42
  • THANK YOU!! OK, so I followed you tip and the switch was easier than i expected. I downloaded the RIA Toolkit installer from you link. Deleted my old service. Created a new DomainService BEFORE i upgraded to EF 4.3 so I got the CRUD scaffolding and saved some time. Upgraded to EF 4.3 and now everything seems to work just fine. Again thanks. – cfs Feb 16 '12 at 22:03
  • I needed the following in my web.config: ` ` – Pakman Apr 02 '12 at 22:25
  • @cfs I've a problem same as yours. Could you please help that how did you use Entity Framework 4.3 (I use EF 5) with WCF Ria services ? – Shahin Oct 27 '12 at 10:17
  • @shaahin Hi, yes I'll try to help, but see a few comments above because I explain most of what I did there. If you could be a bit more spesific on what you have problems with, I'll do my best to answer. Or you could open a new question for it and I'll see if I can answer it there. – cfs Nov 02 '12 at 23:05
0

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.

John
  • 6,693
  • 3
  • 51
  • 90
0

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)

Jone Polvora
  • 2,184
  • 1
  • 22
  • 33