What's the best way of delivering EF models over WCF?

I've got new project on the go and I'm looking at using the Entity Framework (v4) over a WCF service.

I was wondering what peoples views are on the best way of delivering the data from EF over WCF? Should I be using the EF generated classes or wrap them up into something else?

The consuming application will be web for the moment, but possibly others in the future (Silverlight, Windows, mobile etc).

Answers


For Silverlight i would recommend the WCF RIA Services. For web you could use ADO.NET Data Services.

Or you could get a little lower level and write your own bare bones WCF service and surface simple POCOs as transfer objects. This method is the most code-intensive and not for the faint of heart.


In EF 3.5, my advice would be to never return an EF entity. Return a DTO instead, with properties that correspond to those of the EF entity.

In EF 4.0, they've done a lot of work around POCO classes and other things. I'm not up to speed on what they've done. If you can get EF to generate entity classes that do not expose implementation dependencies to clients, then you can return those. The .NET 3.5 classes derived from EF-specific classes, and the base class properties leaked out into the client proxies. You need this to not happen.


Need Your Help

How to force Chrome (or any other WebKit browser) not to use "default" tag names?

google-chrome webkit cross-browser google-chrome-devtools

I was having issues because of Chrome automatically referencing DIV... It works that way in Safari (desktop and mobile), but not in Firefox.

requestAnimationFrame calling at more than 60FPS

javascript html5 requestanimationframe game-loop

I'm making a simple game and I'm having a problem where after minimizing the window for a few seconds, upon return the game runs at twice the framerate, and even more after that, adding 60 each tim...