WCF + OData + EF Code First + Singleton: please publish real-world sample!
I've tried to get an answer to the following request in different forums, e.g. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c91a5988-3298-4ca8-8688-a6fa4558dcf5, however as this is cross-product line, nobody seems to have a best-practice advice.
Can Microsoft please publish a *working* real-world sample, demonstrating the co-existence of classic WCF, OData and EF code first using a singleton object as the root of an object graph:
- a singleton object is the root of an object graph in memory (let's say: a company, its employees and their computers; two 1:n relations)
- the singleton and its graph is accessed using classic WCF for complicated method calls AND by OData services for access by mobile devices.
OData was meant for easy data access, however it turns out to be the afterburner to reach smartphones. WCF never got that effort... So OData must fullfil where WCF falls short.
- How can a WCF service host and the OData service host access the same singleton object? Obviously only if both communications are hosted in IIS. But I am sure that's not enough...
- because I am a database agnostic programmer, I use EF 4.2 code first on top, as an appendix. So how do I set up EF Code first context class for supporting singleton OData and singleton classic WCF? There is a blog entry which doesn't provide enough info for me:
- which methods/constructors are called in what sequence when the service is started? where should the DB be read in? where should the seed data be written in case there is no DB?
- the first question is whether MyEFContext inheriting from DbContext and containing the DbSet properties should be serviced using WCF to the outside world at all. Or if the MyEFContext object should be used for DB I/O only on the side, that means classic WCF and OData services the base object graph to the outside world. The latter looks very good to me, if DB read only happens on service startup and SaveChanges() only on service shutdown.
- the resulting code should be encapsulated in libraries so it can be hosted in a windows service or IIS.
- to make matters more realistic: the objects in the object graph issue events. Those events and their event handlers a) need to be rewired upon reading from the DB and b) events should propagate to the OData clients (smart phones).
I've heard that b) is only possible through Azure using a Windows Phone Notification service. However my company, because of local data protection laws, does not allow to use the cloud.
- And for B**M fans: where and how in classic WCF, Odata and EF can Async be applied for a high-perf server?
I expect many application programmers to start planning and developing this kind of app in 2012. Therefore I ask for such a sample now. I develop software for 35+ years now and this is the best time of my life because of all the new technologies coming out now and saving a lot of „plumbing“ code.
I am willing to create this sample, document and publish it on codeplex, however I need detailed guidance.
Thank you very much!