Frank
Frank

Reputation: 7585

Is there any way to reference entity framework in silverlight?

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!

Upvotes: 0

Views: 982

Answers (2)

Jacob Adams
Jacob Adams

Reputation: 3994

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.

Upvotes: 0

apiguy
apiguy

Reputation: 5362

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/

Upvotes: 2

Related Questions