Well, it’s been a busy week. Unfortunately it hasn’t left me with much time to write any meaningful blog entries – apologies. Last Friday I managed to implement an end-to-end solution for object graph serialization with Entity Framework (v4) POCO objects to and from WCF Web Services (note: for .Net clients only at this stage).
It is a fairly complicated thing to explain, so I’m only going to go into detail if there is sufficient interest in the solution. There is sufficient material to be found on the Internet (see my previous post for links), but it’s certainly not all in one place and you would have to combine aspects of a different example – in the case of supporting serialization back from the WCF client (via a generated proxy).
The summary goes something like this:
- Create edmx model
- Generate POCO entities using the template support
- Split the entities into a separate assembly
- Consume the entities and context via a Web Service (WCF) facade
- Implement a custom attribute to handle EF Proxies
- Implement a custom attribute to handle cyclic references (for entities with a self-reference) – (if needed)
- Implement a custom attribute to be outputted in the client proxy stub – (if needed)
- Use the common assembly with the client and the WCF service
So – in short – if you are interested in a detailed entry (or series of entries) please leave a comment here, otherwise I may get to the subject later in the year when I have more time (and if there is interest).
In other news, I did some work with a WinForms client and TreeView control which was my first Windows Application for quite a while. I’ve got to say, I’m really impressed how easy it is to use TreeView controls in .Net WinForms over MFC/C++. Back in the old days, TreeView controls were a bit tricky to work with – .Net makes it almost too easy.
3 thoughts on “Entity Framework v4 (POCO) and WCF Web Services”
Hi — cool blog. I’ve been lost in Lerman’s book for about a month now, off and on. From what you wrote above, I’m especially interested in how you decided to deal with proxies and WCF. So far, I only know how to modify the T4 to remove dynamic proxies entirely, and thus lose some of the functionality. Whatever info you’d have would be a marked improvement over what I know now.
Hi Dan,
WCF and EF proxies don’t mix well at all! There’s no way I know of to publish them beyond a WCF service boundary, due to the dynamic nature of their types at runtime. Besides that, there are still some additional issues publishing WCF POCO objects (via T4 templates) via WCF, chronicalled here: http://www.sanderstechnology.com/2010/the-ado-net-entity-framework-poco-objects-and-you/10142/
Cheers,
Rob
Interesting blog post