0
votes

I would like to have the EntityFramework4 model (.edmx and .context.tt) in a Class Library called ModelLibrary and the code generated entities incl. the partial classes (.tt) inside a separate Silverlight Class Library called EntitiesLibrary.

This way I was hoping to share the EntitiesLibrary with my silverlight application for self-tracking. In order to consume this project within the silverlight application the class library has to be a Silverlight class library and I think this is where the problem starts.

In the next step I have added a Siverlight Application project and let it to be hosted in a new ASP Web project. In the ASP Web Project I have added a WCF Service and a reference to both ModelLibrary and EntitiesLibrary and created some CRUD operations in there.

Now within the Silverlight Application I add a Service Reference to the Wcf Service, while it can discover the service, when clicking ok; I get an error message:

Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

On the Service.svc.cs - while having no compiling issues - Resharper is showing me some errors on the entities used in the operations:

Module 'System, Version=2.0.5.0, Culture....' should be referenced.

??? Now I am completely stuck. Also unusual is that under references of ModelLibrary and under ASP Web host pointing to EntitiesLibrary I see a yellow marking. This happens only because the latter is of type Silverlight Class library. It doesn't happen if I had a normal class library.

Would be great if somebody had an advice for me, Many Thanks Kave

1

1 Answers

0
votes

I have followed the Jenny Lerman's "Entity Framework" book, where she creates a link to the auto generated entities within a seperate Class Library.

As I had suspected it, if I would use a Console Application instead of Silverlight and have a plain Class Library for my Entities, it would work just fine. The Added Webservice reference can work with the Entities to create a proxy. Just like in the book.

However if the class library is of type Silverlight Class library - due restriction in Silverlight assemblies - the WCF service reference pointing to a CLR 4.0 webservice can't be somehow created due mismatching libraries.

I stopped digging further into this matter and have been since trying to get RIA Services working, which seems far more promosing than Self Tracking POCOs.

Yet the problems with a proper n-Tier infrastructure still remains to be discovered.