Entity Framework 6 Eager Loading

By | December 30, 2016
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest

In this Entity Framework Tutorial, we are going to understand about an important concept related to Object Relational Mapping that is “Eager Loading” with the help of a practical example. We already have discussed eager loading at high level, and another related concept “Lazy Loading” that is opposite to Eager Loading while discussing Entity Framework Interview Questions along with more Entity Framework concepts. To see a practical example for Lazy Loading in Entity Framework, follow here.

Eager loading is the process by which a query loads related entities along with it as part of the query. It is achieved by the using the “Include” method. For example, when querying orders, eager-load their product details also in a single query.

More Practical Entity Framework Tutorial

In order to practically grasp Entity Framework, we highly recommend to go through these real time implementations:


We have created 3 entities, Category, Products and Orders. In below diagram, entities with their relationships look as:Entity Framework Tutorial Eager Loading

The class of Products will look as:

The class of order entity will look as:

Following code does the eager loading in case of products and orders:

Resultant screen will be:EF Tutorial Eager Loading

In order to create an order, we can do as:

  • Learn ASP NET MVC 5 step by step [Maruti Makwana, Corporate Trainer] 28 Lectures, 2.5 Hours Video, Intermediate Level
    Very easy to learn video series on Asp.Net MVC 5 Specially for those who are familiar with Asp.Net Web forms.
  • AngularJS for ASP.NET MVC Developers [Brett Romero] 10 Lectures, 1 hour video, Intermediate Level
    The Fastest Way For .NET Developers To Add AngularJS To Their Resume
  • ASP.NET with Entity Framework from Scratch [Manzoor Ahmad, MCPD | MCT] 77 Lectures, 10 hour video, All Level
    Latest approach of web application development
  • Comprehensive ASP.NET MVC [3D BUZZ] 34 lectures, 14 Hours Video, All Levels
    From zero knowledge of ASP.NET to deploying a complete project to production.
The screen will look as:New Product EF Tutorial

This screen will place an order of products. As we have added foreign key constraint in orders with products. So with eager loading we can load the related product details while loading orders.

EF Eager Loading Example

After reading this Entity Framework Tutorial, it will be easy to implement eager loading in our application. Follow here to understand that correctly choosing between eager-loading and lazy-loading in practical scenarios.

You are working with WebDevTutorial and building an ADO.NET Entity Framework application for a client. You need to validate the conceptual schema definition language (CSDL), store schema definition language (SSDL), and mapping specification language (MSL) files. Which Entity Data Model tool can you use? (Each correct answer presents a complete solution. Choose all that apply.)

  • A. EDM Generator (EdmGen.exe)
  • B. ADO.NET Entity Data Model Designer
  • C. Update Model Wizard
  • D. Entity Data Model Wizard
  • E. All of Above
  • F. None of Above

For a complete online test and Practice Exams on Web Technologies, Click Here.

 Correct Answer: B, D

Top Technical Interview Questions and Answers Series:

ASP.NET MVC Jobs [Updated Daily]

Top ASP.NET MVC Jobs

IT Software Developer
Source: Far Bank Enterprises
Details: Developing applications using Microsoft technologies, including C# and ASP.Net MVC. Far Bank Enterprise is seeking a Software Developer to join our IT team on...  More
15 days ago

Bainbridge Island, WA 04-February-2017

.Net Developer
Source: Ramsoft Systems, Inc.
Details: ASP.Net, MVC Framework, C#, Entity Framework. Hope you are doing well....  More
19 days ago

Richmond, VA 23229 31-January-2017

.NET Developer with Microsoft Active Directory
Source: Ramsoft Systems, Inc.
Details: ASP.Net, MVC Framework, C#, Entity Framework. Hope you are doing well....  More
22 days ago

Richmond, VA 23229 28-January-2017

Software Developer II
Source: Almac Group, Inc
Details: C#, .NET 4.5 or higher, Linq, ASP.NET MVC, Visual Studio 2013 or higher. Almac Group is a group of established businesses at the forefront of the Pharmaceutical...  More
3 days ago

Lansdale, PA 19446 17-February-2017

Junior Level .NET Developer
Source: Levi, Ray & Shoup, Inc.
Details: Time to get to work! LRS Consulting Services is seeking a Junior Level .NET Developer for a 3-6 month contract-to-hire opportunity with our client in Central  More
2 days ago

Illinois 17-February-2017

Software Developer
Source: Indeed
Details: Experience with Microsoft *Visual Studio 2013+* and *C# 4.5.* Experience creating *WCF* and *Web API* services. Understanding of *object oriented design* &   More
24 days ago

Redmond, WA 26-January-2017

Software Developer - Operations
Source: Hudl
Details: You’ll likely be working with technologies like React and Bootstrap, C# and ASP.NET MVC, MongoDB, and a number of AWS services....  More
12 days ago

Lincoln, NE 68508 07-February-2017

Junior .NET Developer
Source: SBG Technology Solutions
Details: Must have a clear understanding of ASP.NET MVC, and MVC application design pattern experience. At least five (5) years of development experience, including 4+...  More
5 days ago

Alexandria, VA 22314 14-February-2017

Software Developer
Source: Indeed
Details: *Michigan based applicants ONLY* Equal Opportunity Employer; E-Verify Participant _\*Please do not apply if you are not legally authorized to work in the  More
4 days ago

Lansing, MI 15-February-2017

Software Developer
Source: Indeed
Details: _Experience with Microsoft .NET C# and ASP.NET, MVC, & Entity Framework_. Intellicheck Mobilisa is a publicly-traded technology company located in Jericho, NY...  More
5 days ago

Jericho, NY 14-February-2017

Junior .NET Developer
Source: Publishers Clearing House
Details: Windows Forms, WCF, ASP.NET, MVC. Publishers Clearing House (PCH), headquartered in Port Washington, NY (soon to be Jericho, NY!)....  More
30+ days ago

Port Washington, NY 11050 12-December-2016

Software Developer
Source: Altruista Health
Details: Deep technology experience, including ASP.Net, MVC, C#.Net, SQL Server 2008, and SQL Server 2012. Altruista Health, Inc., is seeking an experienced professional...  More
12 days ago

Reston, VA 20190 07-February-2017

.Net Developer
Source: Indeed
Details: MVC:. Develop web, web services and back-office applications using the newest Microsoft stack of technologies including Net CORE, ASP.NET, MVC, Angular,...  More
2 days ago

Charlotte, NC 17-February-2017

ASP.NET/Angular Developer
Source: Intellisoft Technologies
Details: No new resumes ASP.NET/Angular Developer BlackHawk 700 State Hwy. 121 Bypass Suite 200 Lewisville, Texas 75067 6+ Month Contract Industry leading Client...  More
30+ days ago

Dallas, TX 05-January-2017

Certified Microsoft .NET Developer
Source: Indeed
Details: The project includes .Net MVC web applications with heavy use of JavaScript, jQuery and Kendo UI components....  More
4 days ago

Madison, WI 15-February-2017

.NET Developer
Source: NYC Careers
Details: Experience building full-featured software with ASP.NET MVC, WebForms, VB.NET, SQL and Javascript. The Kings County District Attorney's Office, located in the...  More
4 days ago

Brooklyn, NY 15-February-2017

.Net Developer
Source: Indeed
Details: ASP.NET MVC, JQuery, Entity framework, HTML programming. .Net MVC 4.0 and Strong experience in designing and developing layered web based applications with...  More
18 days ago

Bellevue, WA 01-February-2017

.NET DEVELOPER
Source: Indeed
Details: ASP.NET MVC, JQuery, Entity framework, HTML programming. .Net MVC 4.0 and Strong experience in designing and developing layered web based applications with...  More
18 days ago

Seattle, WA 01-February-2017

Software Engineer C# .Net Developer
Source: MorphoTrust
Details: Responsible for software design and implementation (C#/.Net, ASP.Net MVC, SQL Server, Javascript), testing, debugging, assurance testing, and creation of...  More
30+ days ago

Bloomington, MN 18-January-2017

Software Development Engineer I
Source: Apptio
Details: You: You are a software engineer who strives for excellence in the user’s experience as well as in your technical solutions. You have a curious mind and a...  More
30+ days ago

Bellevue, WA 05-January-2017

NET DEVELOPER - SENIOR (FULL-TIME CONTRACTUAL)
Source: State of Maryland
Details: ASP.NET MVC with Razor. SQL Server 2012, Visual Studio 2015, .NET 4.6 and MVC 5. Development, maintenance, trouble-shooting and debugging of .NET applications...  More
2 days ago

Baltimore, MD 17-February-2017

Developer - Full Stack ASP.NET MVC, C#, SQL Server
Source: Indeed
Details: ASP.NET MVC, C#, SQL Full Stack Server Developer (Austin, Tx)*. Who We Are ...*....  More
2 days ago

Austin, TX 78759 17-February-2017

Mid .Net Developer
Source: Indeed
Details: *Secret Clearance Required!!!!* Current contract until 2020! This highly responsible position involves using established work procedures to analyze, design,  More
5 days ago

Herndon, VA 20171 14-February-2017

Senior Developer
Source: Indeed
Details: Knowledge or experience in ASP.NET, MVC 3+, WCF, ADO.NET. NO C2C PLEASE*....  More
6 days ago

Chicago, IL 60654 13-February-2017

Software Engineer/Developer
Source: ITR (Information Technology Resources)
Details: Candidates demonstrating applied experience with ASP.NET MVC, Java, and Linux will be given extra consideration....  More
30+ days ago

Oak Ridge, TN 08-January-2017
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest