Eager Loading custom datatypes?

Topics: Web Api
Dec 10, 2011 at 1:52 AM

Sorry if this has been asked before, but I have what should be a simple scenario.

Say I have object A that has object B as a virtual property:

public class ObjectA
    public int ObjectAId { get; set; }
    public string name { get; set; }
    public virtual ObjectB User { get; set; }

Using EF Code First, my query works as expected (ObjectB is hydrated in my linq query).  My service is returning IQueryable<ObjectA> -  This is an OData service.  However WCF isn't able to serialize ObjectB.  (Using the Service Trace Viewer, I get a "Failed to send response message over HTTP" error - so I am assuming this is a WCF serialization issue). 

I thought setting context.Configuration.ProxyCreationEnabled = false would do the trick, but no such luck.  Is there something else I need to do when building my DbModelBuilder? (I would prefer to use fluent configuration vs. using attributes on my POCO classes).