Back to Browse

Lazy Loading in Entity Framework Core

2.7K views
Oct 9, 2020
25:16

Previous video Link (Part 8) https://youtu.be/Nz4jRKAM_-w In this video we will discuss Entity Framework Core Lazy Loading and Explicit Loading in ASP .NET Core Web Application. Lazy loading loads only the parent entity first and loads the related data only when it is accessed by the property accessor. For lazy loading to work, one of the must requirement is Virtual Navigation property and the Navigation property of the domain model must be public. Asp.NET Core Application will throw a runtime error if any property is not defined as virtual while using Lazy loading. Lazy loading is not readily available like Eager loading or Explicit loading. It needs Entity Framework Core Proxy libraries to be installed and configured. Lazy Loading is very useful when you have a lot of referenced objects in your Domain model and not all the reference objects are needed all the time. Lazy and explicit loading passes multiple SQL Queries to the database. In Explicit Loading, only the parent entity is loaded and we need to explicitly load the referenced entities or child collection entities specifically. In Explicit loading, Every referenced or collection entities requires a separate SQL query to load the entities from the database. Explicit loading is not suitable if you are populating a large no of Entities in a loop. Because it may results in sending multiple SQL queries to the database. it is best to use the Eager loading on that case. And much more in this video, please watch it to learn more.....

Download

0 formats

No download links available.

Lazy Loading in Entity Framework Core | NatokHD