Partager via


Lazy loading in Entity Framework

Recently, I wrote this little article that got published in the new Insights sidebar in MSDN Magazine. In it, I mention one of the fundamental tenets of ADO.NET: 

*Network roundtrips should not be hidden from the developer*

But guess what... It is not always the case that there is a network (or even a process boundary) between your application and your database. Also, there are many scenarios in which you know that most of your data seldom changes or that you don't care if things changes a bit while your application is running (think of a cache). In those circumstances, implicit lazy loading just makes sense.

We have been sending out the message that you can get implicit lazy loading by changing the standard code generation process in Entity Framework.

My colleague Jarek went far further and created an experimental set of entity classes that completely replaces the default code-generated classes in EF. And his implementation actually includes some very cool ideas that go beyond lazy loading.

Take a look at his post. And you can find the bits (compatible with the just released Visual Studio 2008 SP1 Beta) from our portal in Code Gallery.

Update: Just wanted to add some relevant links to customers asking for lazing loading in EF:

Comments

  • Anonymous
    May 19, 2008
    There has been a lot of discussions lately about Entity Framework and Lazy Loading as well as some solutions