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 8322769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:29:43+00:00 2026-06-08T23:29:43+00:00

I am using entity framework 4.3.1 against a sql server 2012 database and I

  • 0

I am using entity framework 4.3.1 against a sql server 2012 database and I have a database with these tables (there are more but the relevant bits are below):

Customer

    CustomerNumber nvarchar(10) not null primary key

SalesDocument

    SalesDocumentNumber nvarchar(10) not null primary key
    CustomerNumber nvarchar(10) not null

I am running the following snippet of code:

const string docNumber = "111348718";
IQueryable<SalesDocument> docs = factory.CreateSalesDocumentRepository().All;

var ssd = docs.Single(s => s.SalesDocumentNumber.Equals(docNumber));

if (ssd.Customer == null)
    Console.WriteLine("NOOOOOOO");

ssd = docs
    .Include(s => s.Customer)
    .Single(s => s.SalesDocumentNumber.Equals(docNumber));

if (ssd.Customer == null)
    Console.WriteLine("YESSSSSS");

and I get only NOOOOOOO printed.

So it seems that the lazy loading is not working but eager loading is.

What gives and how on earth can I debug what has gone wrong in this scenario (what are likely causes for this to fail – it feels like a bug in EF to me but I am holding off on declaring that and throwing the whole steaming pile out of the window)? Surely the configuration is OK if the second one is working fine…?

  • 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-08T23:29:45+00:00Added an answer on June 8, 2026 at 11:29 pm

    I don’t mean to teach you to suck eggs, but have you enabled LazyLoading in your ObjectContext?

    ie: in the ObjectContext constructor

     this.ContextOptions.LazyLoadingEnabled = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Entity Framework 4.3.1 against a SQL Server 2012 database and I
I am using Entity Framework and I have two tables, a contact relationship table
Using Entity Framework 4 with stored procedures and SQL Server 2008 SP1... When running
I am using Entity Framework 4.1 to perform CRUD operations against my database. I
I am using SL 4, WCF RIA Services against Entity Framework 4.0. I have
When using Entity Framework 4.1, are there alternatives to the naming conventions for Navigation
We are running several calls against a SQL Server database within a transaction scope
I am having trouble with SQL Server creating Foreign Key constraints when using Entity
Background We have a WinForms application with Entity Framework 4.2 code-first / FluentAPI using
I have an application that contains methods that work with data using Entity Framework

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.