Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8957721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:03:25+00:00 2026-06-15T15:03:25+00:00

I am having problems understanding lazy loading in Entity Framework 5. I understand when

  • 0

I am having problems understanding lazy loading in Entity Framework 5. I understand when using lazy loading related entities are not loaded until requested:

“When using Lazy Loading, your initial query only brings in the target
entity set. But whenever you access a navigation property, another
query is issued against the store to load the related entity.
(reference)”

I have a ASP.NET Web API project with two classes:

public class Farm
{
    public int FarmId { get; set; }
    public virtual ICollection<LandUnit> LandUnits { get; set; }
    ...
}
public class LandUnit
{
    public int LandUnitId { get; set; }
    ...
}

I set LazyLoadingEnabled = true, and have my POCO classes conforming to the guidelines (reference), but when I use scaffolding to create a FarmController and call it through fiddler, it shows:

JSON
    {}
        ...
    LandUnits
        {}
            ...

If I set LazyLoadingEnabled = false, then I get:

JSON
    {}
        ...
    LandUnits=(null)

Am I misunderstanding the basics of lazy loading? It appears to me that what is occurring is the opposite of what the definition states. When lazy loading is off, related entities are not loaded. When lazy loading is on, related entities are loaded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:03:25+00:00Added an answer on June 15, 2026 at 3:03 pm

    This is expected behaviour. When the JSON serializer comes to serialize the type, it will enumerate the LandUnits navigation property which will of course invoke the lazy load of that collection from the database.

    When you switch lazy loading off, your navigation property will still be set to its default value as demonstrated, as no proxy type will be generated by Entity Framework.

    I would recommend keeping lazy loading switched off, and eagerly (using the Include method) or explicly loading (using the Load method) the related data to ensure you aren’t inadvertantly loading data that you don’t require.

    You should also be aware of circular dependency problems when using the default JSON serializer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems understanding how latest.integration works. I have an example that is not
I'm having problems understanding why following code leaks in one case, and not in
I'm having some problems using / understanding is_dir. (Yes, I have read the PHP
I've just started using LINQ and I'm having a couple of problems understanding how
I'm having problems understanding what's going on in the following situation. I'm not familiar
I'm having problems understanding how preventDefault function works. I created a simple jsfiddle, but
I am having problems understanding how to make complex queries (or even simple ones)
I am relatively new to C++ and am having problems understanding struct. I have
We are having problems with understanding the different between the QUORUM and TWO ConsistencyLevel
I'm having problems with understanding how jQuery create headers for ajax post. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.