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

  • Home
  • SEARCH
  • 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 9052361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:09:01+00:00 2026-06-16T13:09:01+00:00

I am teaching myself about the entity framework using a tutorial found at http://msdn.microsoft.com/en-us/data/jj591506

  • 0

I am teaching myself about the entity framework using a tutorial found at http://msdn.microsoft.com/en-us/data/jj591506.

using (var db = new DatabaseEntities())
{
            // Section 1
            var section = new Section
            {
                SectionID = 1,
                SectionLetter = "d"
            };
            db.Sections.Add(section);
            db.SaveChanges();

            // Section 2

            var query = from b in db.Sections 
                        orderby b.SectionLetter
                        select b;

            foreach (var item in query)
            {
                this.Title = item.SectionLetter;
            }
}

When I use section 1 and section 2 of the code above together they work well. However, when I run just Section 2 the title does not change which means it does not even return a single item and thus does not enter the foreach loop. I can’t see why it would not enter the loop.

I realise there is probably an obvious answer to this question but I thought I should ask on stackoverflow rather than ask a colleague so others with the same question could find an answer.

I suspect there might be a clue in this question: System.Data.Entity not working as expected for MVC Entity Framework. Unfortunately I can’t seem to work it out.

  • 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-16T13:09:03+00:00Added an answer on June 16, 2026 at 1:09 pm

    It looks like the line var db = new DatabaseEntities() is connecting to a database that doesn’t have any rows. Check the Connection property of db to make sure it is on the correct server/instance/file.

    You should be able to see the contents of the table if you perform a “Quick Watch” on query.ToArray().

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

Sidebar

Related Questions

I am teaching myself about the entity framework using a tutorial found at http://msdn.microsoft.com/en-us/data/jj591506
I'm teaching myself some Django tonight using the local dev package at instantdjango.com I
I am currently teaching myself about various data strutures and am a little frustrated
I am teaching myself about web programming. I am trying to create a user
My disclaimer here is that I started teaching myself C++ about a week ago
Teaching myself the flow of data from mySQL -> PHP -> JSON / Javascript
I'm teaching myself Rails through PragProg's (apparently outdated - I'm using Rails 3.2.3) Rails
Ok, I've been teaching myself PHP and doing little projects for about 40 hours,
I have started teaching myself about the Android NDK and I have followed this
I just started teaching myself Linq to SQL today. I hardly know anything about

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.