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

Software Engineer – Full Stack
Source: Indeed
Details: 5-7 years of experience with the Microsoft .NET UI development stack (ASP.NET MVC & WCF). At Upfront, we make every visit valuable for patients and providers....  More
2 days ago

Chicago, IL 13-December-2017

Full-Stack Software Engineer, ASP.NET
Source: Indeed
Details: C#, ASP.NET MVC, Entity Framework, SQL Server. Ideal candidates have demonstrable experience building highly scalable, secure applications leveraging the ASP...  More
30+ days ago

New York, NY 17-October-2017

C# Software Engineer
Source: Indeed
Details: 1+ years of experience with web development with ASP.Net MVC and JavaScript. CRISP - The State of Maryland Health Information Exchange is a regional health...  More
30+ days ago

Columbia, MD 13-September-2017

Software Development Engineer
Source: Indeed
Details: Experience implementing a RESTful API using ASP.NET MVC 4. We are seeking a talented Software Engineer to contribute to the development and maintenance of an...  More
30+ days ago

Des Moines, IA 06-November-2017

Software Development Engineer II - 4071
Source: Indeed
Details: Experience with ASP.NET MVC (especially Razor views and HTML helper extensions). ISoftStone North America is seeking a Software Development Engineer II to join...  More
4 days ago

Redmond, WA 12-December-2017

Software Engineer
Source: Indeed
Details: You will use your technical expertise and problem solving skills to develop a wide variety of operational grade software solutions (i.e., ASP .NET MVC web...  More
10 days ago

Herndon, VA 05-December-2017

Software Engineer
Source: Indeed
Details: Proficiency with ASP.NET MVC, C#, and SQL. Is the leading Digital Health technology company servicing the needs of the emergency and public safety industries....  More
24 days ago

Broomfield, CO 80021 21-November-2017

Software Engineer
Source: Indeed
Details: C#, ASP.NET MVC and/or Java. This position will exercise the applicant’s skills as a software engineer in both the commercial and government space....  More
30+ days ago

Johnstown, PA 15904 19-October-2017

Software Engineer
Source: Indeed
Details: NET, ASP.NET MVC and Razor Syntax. About the Role*....  More
30+ days ago

Columbus, OH 19-October-2017

Software Engineer
Source: Indeed
Details: API first design and SPA applications with Angular, Web API and ASP.NET MVC. NCARB’s Information Systems (IS) Directorate has an opening for a Software Engineer...  More
30+ days ago

Washington, DC 20006 13-October-2017

Software Engineer
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
30+ days ago

Long Island, NY 05-September-2017

Senior .NET Consultant
Source: Indeed
Details: EPE Innovations is a software development and consulting company, with a primary focus on Complex Data Modeling, Data Analytics and Business Intelligence...  More
7 hours ago

Houston, TX 15-December-2017

Senior .NET Consultant
Source: Indeed
Details: ASP .Net MVC.:. Strong knowledge of our core technology stack including n-tiered .Net development, TFS, MVC C# .NET, .NET Entity Framework, WCF web services, MS...  More
1 day ago

Albany, NY 14-December-2017

ASP.NET MVC Web Developer
Source: Indeed
Details: Strong or expert knowledge of C#, JQuery, JavaScript, Knockout JS, ASP.NET MVC, MSSQL. Perform in a key role in the development and enhancement of enterprise...  More
14 days ago

Evanston, IL 01-December-2017

Associate Software Engineer
Source: Indeed
Details: Experience with .NET Framework (ASP.NET, MVC, WinForms). American Healthtech, a growing software technology company, is searching for an *Associate Software...  More
7 days ago

Ridgeland, MS 39157 08-December-2017

Software Engineer Associate
Source: Indeed
Details: Familiarity with Angular, Entity Framework and ASP.NET MVC. 30% Application Development*....  More
15 days ago

Dallas, TX 30-November-2017

Software Engineer I
Source: Indeed
Details: Knowledge and experience with .NET MVC and web-based development. .NET 4 or greater, ASP.NET MVC 4 or greater, javascript frameworks such as JQuery....  More
7 days ago

Ridgeland, MS 39157 08-December-2017

ASP.NET Web Developer
Source: Indeed
Details: C# and ASP.NET MVC programming:. Develop new ASP.net MVC applications conforming to the design specifications provided....  More
30+ days ago

Orlando, FL 08-November-2017

.Net Developer (C#, ASP.Net)
Source: Indeed
Details: 2+ years' experience with ASP.NET MVC, at least 1 year using the 4-4.5 framework. This individual will assist with the development and maintenance of detailed...  More
18 days ago

Nashville, TN 27-November-2017

.Net Developer (C#, ASP.Net)
Source: Indeed
Details: 2+ years' experience with ASP.NET MVC, at least 1 year using the 4-4.5 framework. Proficient working with the following - .NET, C#/VB, SSMS, Object Oriented...  More
18 days ago

Cleveland, OH 27-November-2017

Sr. Software Engineer
Source: Indeed
Details: Experience with ASP.NET MVC. Looking for a highly skilled software engineer to provide technical leadership on its critical communication software suite....  More
8 days ago

Eden Prairie, MN 07-December-2017

Sr. Software Engineer
Source: Indeed
Details: Experience with ASP.NET MVC. Client is looking for a highly skilled software engineer to provide technical leadership on its critical communication software...  More
30 days ago

Eden Prairie, MN 15-November-2017

Sr. Software Engineer
Source: Indeed
Details: Extensive Experience with ASP.NET MVC using C#.NET. We are looking for a Sr....  More
30+ days ago

San Jose, CA 01-November-2017

Sr. Software Engineer
Source: Indeed
Details: Full stack development experience using C#, ASP.Net, MVC, WCF, REST APIs, SQL Server, JavaScript Frameworks, HTML5, CSS3,. Local Candidates Preferred....  More
30+ days ago

Burbank, CA 22-September-2017

Senior .NET Programmer/Analyst - 5+ Yrs Experience - Philadelphia, PA
Source: Marshall Dennehey Warner Coleman & Goggin, P.C.
Details: A minimum of 5 years experience in application design and development using a variety of .NET technologies and languages, including C#, VB.NET, Javascript,...  More
30+ days ago

Philadelphia, PA 26-October-2017
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest