after a lot of help yesterday, I came up against a known error in asp.net4 beta - I upgraded to VS2012 RC Express (4.5), and now I\'m getting an internal server error, and I
To resolve the error 500 issue when returning JSON with entities with virtual keyword I did the following,
public class BookingsController : ApiController
{
private BookingsContext db = new BookingsContext();
// GET api/Bookings
public IEnumerable GettblCustomerBookings()
{
db.Configuration.ProxyCreationEnabled = false;
return db.tblCustomerBookings.AsEnumerable();
}
}
It's enough to disable proxy creation (which disables lazy loading as well) for the specific circumstances where proxies are disturbing, like serialization. This disables proxy creation only for the specific context instance of db
db.Configuration.ProxyCreationEnabled = false;
http://blogs.msdn.com/b/adonet/archive/2011/01/31/using-dbcontext-in-ef-feature-ctp5-part-6-loading-related-entities.aspx
http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-1-introduction-and-model.aspx