8
Nov

Implicit lazy loading on by default in EF4

The last beta (Beta 2) of Visual Studio 2010 with EF4 contains one “interesting” change. The implicit lazy loading is turned on by default. And I’m not sure I like it.

I can handle the fact, that there was a strong demand for it (as Julie pointed) and that for LINQ to SQL people or beginners this may be much easier. But from a database guy perspective this is hidden evil, especially if you’re not the only one developer in project. You don’t know when you’re hitting the database and maybe worse, everything seems to be working fine (all data are there), but it’s a performance problem when you deploy the application from local/test environment. And how surprising will it be, when the context will be gone.

Maybe I change my opinion after trying to work with it. But now, I’ll rather use eager loading or I’ll be explicit with my calls to database. To be on safe side. What do you think?

  • Twitter
  • Facebook
  • Share/Bookmark

There's 1 Comment So Far

  • Craig Stuntz
    November 9th, 2009 at 15:39

    I also dislike lazy loading (for the same reasons as you), but at least it can be turned off easily.

    I’m also concerned that default lazy loading might cause people to not learn to project in LINQ, which, IMHO, is the essence of using the EF.i

Share your thoughts, leave a comment!