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

.Net Support Engineer
Source: Indeed
Details: Good knowledge of ASP DOT NET with C Sharp. .NET / Angular JS or KnockOut JS / ASP.NET MVC / C#.NET / SQL Server / Web API. .Net Support Engineer....  More
1 day ago

New York, NY 21-June-2017

Software Developer (.NET)
Source: Advantech
Details: Back-end coding skills using C#, ASP.NET MVC, Web API, MS-SQL / T-SQL. Responsibilities include design, new development, testing and maintaining MVC - based web...  More
29 days ago

Carol Stream, IL 60188 25-May-2017

C# .Net Developer (Locals Only)
Source: Indeed
Details: 3.AngularJS, ASP.NET MVC, JQuery, HTML5. 1.Good in C# and Microsoft .Net....  More
15 hours ago

Redmond, WA 22-June-2017

Software Engineer. Net
Source: Indeed
Details: JQuery, SSRS, Design Pattern, ASP.NET MVC, and UML, Microsoft Test Manager. C#, ASP.NET with MVC, SQL Database 2012/2014, and Business Analysis, Report Services...  More
1 day ago

Boca Raton, FL 33487 21-June-2017

.NET Software Engineer
Source: Indeed
Details: 5+ years experience in C#, Asp .Net, MVC. O MVC, MVVM, pub-sub pattern, factory pattern, IOC and client server systems....  More
2 days ago

Atlanta, GA 20-June-2017

.NET Developer
Source: Skills Provision Ltd
Details: O ASP.NET MVC 4+. O Telerik UI for ASP.Net MVC. Are you ready for your next challenge?...  More
30+ days ago

Houston, TX 04-May-2017

.Net Software Engineer
Source: Indeed
Details: Strong experience in developing Web Applications using C#.Net, ADO.NET/Asp.Net MVC, jquery, JavaScript, CSS, WEB APIs, SQL Server....  More
22 days ago

Sunnyvale, CA 31-May-2017

C# / .NET Developer
Source: Veterans Sourcing Group
Details: Web Development with JavaScript and ASP.NET MVC. C# / .NET Developer....  More
1 day ago

Jersey City, NJ 07310 22-June-2017

C# .Net Developer
Source: Indeed
Details: Net 4.5+, C#, SQL Server 2012, ASP.Net MVC, Visual Studio 2015. We are looking for c# full stack developer....  More
2 days ago

Fremont, CA 20-June-2017

Senior .Net Developer
Source: Indeed
Details: MVC:. The candidate also will work on the new custom modules/web sites developed in ASP.NET MVC C# platform. Job description (short):....  More
23 hours ago

Harrisburg, PA 22-June-2017

.NET/C#/JavaScript Web Programmer
Source: Indeed
Details: ASP.NET MVC Framework, especially MVC 4. INET is currently hiring detail oriented programmers to join our web development team....  More
1 day ago

Waukesha, WI 21-June-2017

C#/.Net/MVC Developer
Source: RevolutionInsure
Details: If you are a seasoned full stack .NET MVC developer interested in a startup. Experience developing within a Windows environment using Microsoft’s Visual Studio...  More
9 days ago

Austin, TX 13-June-2017

APPLICATION SYSTEMS PROGRAMMER II
Source: The State of Florida
Details: Visual Studio 2013/2015, TFS 2013, ASP.Net MVC, Single Page Applications, and Web Services. Highway Safety and Motor Vehicle....  More
7 days ago

Tallahassee, FL 32399 15-June-2017

C# / .Net Developer
Source: Rumba Info Solutions
Details: Two+ (2) years HTML5, ASP.NET MVC, JavaScript, CSS, jQuery, Angular, Telerik, JSON, XML. C# / .Net Developer will guide, design and develop our next generation...  More
16 days ago

Detroit, MI 06-June-2017

C# .Net Developer
Source: Indeed
Details: Object-oriented analysis and design, .NET (C#, ADO.NET, Entity framework, ASP.NET MVC, LINQ, WinForms), SQL Server, XML, HTML, JavaScript, JQuery, CSS, MVC...  More
17 days ago

Malvern, PA 05-June-2017

Software / Support Engineer - Relocate OK
Source: PetDesk
Details: Experience developing web applications built on ASP.NET MVC. We’re PetDesk and we work in the best industry in the world....  More
5 days ago

San Diego, CA 18-June-2017

Mid-Level .Net Developer
Source: Centare
Details: We are currently looking to add a .Net Developer to our consulting team in Madison. This person will be responsible for contributing to local clients'  More
30+ days ago

Madison, WI 10-April-2017

C# .Net Developer
Source: Indeed
Details: Expertise in ASP.NET MVC 4 Framework · Working experience on HTML5 and CSS3 · Good understanding of .Net 4.5 · Experience working with REST and SOAP Web...  More
20 days ago

Washington, DC 02-June-2017

C# .Net Developer
Source: Indeed
Details: Web development using ASP.Net MVC, HTML5, CSS, JavaScript and JQuery. C# .NET DEVELOPER*....  More
21 days ago

Naperville, IL 01-June-2017

Entry or Junior C# .Net Developer
Source: Indeed
Details: Requirements: • BS degree in computer science, software engineering, or closely related field. • 1+ years of experience in software development. •  More
21 days ago

City Industry, CA 01-June-2017

Lead .Net Developer
Source: Indeed
Details: .NET MVC, Entity Framework, SQL, Front end, ASP.Net, C#*. Strong expertise with C#, ASP.Net MVC, Entity Framework, OOPS Concepts, Web API and WCF services....  More
13 hours ago

Orlando, FL 22-June-2017

ASP.Net C# Developer
Source: Career Evolutions
Details: Classic ASP (for conversion of legacy applications). 5+ years of ASP.NET, MVC and C# experience. Career Evolutions is looking for an ASP.Net C# Developer for a...  More
22 days ago

Scottsdale, AZ 85261 31-May-2017

.NET Software Engineer
Source: Indeed
Details: You have strong programming skills with .NET (C#) and related frameworks (ASP.NET, MVC, WebAPI, etc.). Gavant builds custom software to innovate and solve...  More
30+ days ago

Troy, NY 12180 04-May-2017

Dot Net Developer
Source: Indeed
Details: ASP.NET MVC, JQuery, Entity framework, HTML programming. Develop enterprise web or desktop applications using *Microsoft .NET, ASP.NET, C#, application...  More
15 days ago

Redmond, WA 07-June-2017

Lead Developer
Source: Indeed
Details: XML, XSL, CSS, HTML, ASP/ASP.NET, MVC, JavaScript, Entity Framework, GIT as well as SQL Server, and other relational databases....  More
7 days ago

Cleveland, OH 15-June-2017
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest