views:

28

answers:

2

Hi all,

I have a SOA application. 1. data layer: Entity Framework 2. Service layer: WCF 3. presentation layer: silverlight

Now, in silverlight I want to use data types from data layer. I cannot add a direct reference to entity framework because silverlight is using a different .net CLR. So I added a service reference hoping it will recreate thoses types in reference.cs. However, it still doesn't work. The service call return a error message "The remote server returned an error: NotFound.". This only happens when the service function has a entity framework data types as return type. If a function returns a common type like a string, everything will work. So I am almost sure the problem is caused by type translation.

Does anybody know how to reference data types defined in entity framework, in a silverlight project.

Thank you very much!

+2  A: 

I believe the current recommended practice when exposing your Entity Data Model to a Silverlight client is to use the new .NET WCF RIA Services. Here is a screencast introduction:

http://www.silverlight.net/learn/videos/all/net-ria-services-intro/

and here is the home page for .NET RIA Services:

http://www.silverlight.net/getstarted/riaservices/

free-dom
I think that WCF DataServices with the underlying OData (http://www.odata.org) are equally recommended.
Przemek
@Przemek - I partially agree, especially since OData is an endpoint exposed by .NET RIA Services.
free-dom
Thanks for your answering;Can I host the domain service in a WCF project instead of the Web project? I really want to seperate them. I added the WCF project as a RIA reference in my silverlight project and create domain service in it. Everything builds, however, the service call failed. I don't know if there is any configuration I need to fix if I want to host it in WCF project?? Thank you very much!
OK. I found the answer. I can't because silverlight must start from a project where RIA is hosted.I don't know why microsoft wants to do this. I really want to seperate web client and web service, but RIA put them together...
A: 

I have been able to simply add a reference to a WCF service that returns entity types. When you do that, Visual Studio will build up similar types in your Silverlight project.

Another option is to use the POCO option in Entity Framework 4. If you create a class library in .NET and then create an identical class library in Silverlight (you can just add the .NET classes using 'add as link'), you should be able to use the same types in your Silverlight app, just make sure to check the "Reuse types in specified referenced assemblies" in the service reference configuration.

Jacob Adams