Entity structure in layered architecture?

Performing some experiments around WCF and Entity Framework. A few questions.

Option 1:

I understand that entity infrastructure classes can be serialized through WCF directly, from sp1 onwards. Be that as it may, I would like to know how scripts such as delayed loading, loaded loading, context management, etc., are processed, if they are processed at all?

Option 2:

Another alternative would be to use the EFPocoAdapter to have a simple POCO wrapper on top of the entity structure, instead of directly exposing the entity infrastructure classes. http://code.msdn.microsoft.com/EFPocoAdapter . Has anyone used this? Any thoughts in this direction?

Other thoughts:

About ADO.NET Data Services. As far as I understand, ADO.NET data services cannot be configured for remote access (nettcp binding)? It only supports HTTP access. We all know that binary serialization is slower.

Any pointers or any other parameters?

+4
source share
3 answers

I did something about this, and here are my conclusions on this.

ADO.NET Data Services:

You can use ADO.NET data services (you need SP1) to expose the Entity structure through a wire with almost zero code. But, as I understand it, the only limitation is a transaction over HTTP. This means that in terms of serialization, there is little overhead (we all know that binary serialization is faster), but the advantage is the speed of implementation of our services.

I got an unofficial word from John [ http://twitter.com/John_Papa] about it - "Definitely more parameters with wcf. More work in most cases, too, Astoria easily reveals entities. Perf differences in most cases are insignificant"

Advantages - you don’t need to write any services at all - you can simply connect the validation and security logic around the data services and entity infrastructure, and we are done. Ideally, if you consume data-oriented services over http - in scenarios, for example, with the silverlight client, or with the winform / wpf interface over http.

WCF entity structure mapping:

With SP1, there is a lot of support for using entity structures in layered architectures. This includes support for intensive loading and context management. Of course, in this case we need to write services (and the logic of our methods). Or, if we have an entity framework model that is fully tied to db, we could generate most of the services, including the methods we need.

We recommend that you read http://msdn.microsoft.com/en-us/magazine/cc700340.aspx

Another alternative would be to use the EFPocoAdapter to have a simple POCO wrapper on top of the entity structure for dtos, instead of directly exposing the entity infrastructure classes. Right now this is a compass project for the next version of the Entity infrastructure http://code.msdn.microsoft.com/EFPocoAdapter .

+4
source

It is a very bad idea to expose EF classes over WCF. Microsoft made some serious mistakes that prevent it from being a useful script. They exposed objects as contrracts data, but also the base entity classes and backlinks, expose two copies of the link.

On the other hand, it seems that ADO.NET data services have some magic that allows something close to it to work. Read the SilverLight article this month in the MSDN journal, for example, on the client side, about using ADO.NET data services.

+2
source

Do not pick up the old mail, but ... I found this ad dealing with the same problem. We have WCF services and an Entity Framwork domain model. In the end, I ended up creating T4 based on the work of Danny Simmons, which accepts EDMX and builds POCO message classes along with extension methods that display entity.ToMessage () and message.ToEntity (objectcontext).

This seemed like the best intermediate approach before .NET 4.0, since it does not require additional external project dependencies or hoops, like other methods that I found (based on PostSharp).

If anyone else thinks this approach will be useful, let me know and I will send a link to the TT file on our googlecode site.

0
source

All Articles