How do I eagerly Include the child and grandchild elements of an entity in Entity Framework Code First?

Also, it isn’t necessary to use the string overload. This method will work too:

var customers = db.Customers.Include(c => c.Books.Select(b => b.Author));

For more examples see the EF team blog post:
http://blogs.msdn.com/b/adonet/archive/2011/01/31/using-dbcontext-in-ef-feature-ctp5-part-6-loading-related-entities.aspx

And this tutorial:
http://www.asp.net/entity-framework/tutorials/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)