Lazy loading and Eager Loading are not same in EF Core

Lazy loading will load data or resources upon request made by the user.
This approach generally enhances or optimize application speed and memory by loading only essential data or resources, rather than loading all data from database on very first time ,when it is getting loaded from database.

Let us consider following example of BusDetails and BusFeatures.First we will create BusDetails entity and next we will create BusFeatures.

public class Busdetails
{
public int busid{get;set;}
public string busfrom{get;set;}
public string busto{get;set;}
public date journeydate{get;set;}
public string busname{get;set;}
public string boardingpoint{get;set;}
public string destinationpoint{get;set;}
 public virtual Icollection<BusFeatures> BusFeatures{get;set;}
}

public class BusFeatures
{
public int busfid{get;set;}
public string busfeature{get;set;}
public int busid{get;set;}
 public virtual Busdetails{get;set;}
}
In above code,Each bus has different or multiple features like ChargePoint,WaterBottle,Bedsheet,Pillow,Toilet etc.But these features will be available for specific bus only.For example, some buses will not have Toilet facility.One bus has many features ,so it is one to Many relationship.
public class AppDbContext:DBContext
{
public DBSet<Busdetails>{get;set;}
public DBSet<BusFeatures>{get;set;}
}
In the below scenario,it retrieves list of busdetails,but we dont need busfeatures unless it is explicitly asked by customers.
using (var context=new AppDBContext())
{
var fullbusdetails=context.busdetails.ToList(); //retrieves full bus details
foreach(var features in fullbusdetails)
{
console.writeline($"Bus name{features.busname}")
                    console.writeline($"Bus Feature{features.busfeature}")
}
}

Eager Loading are not same as Lazy loading in EF Core

Eager loading means with single query should retrieve necessary data and its related entities.It reduces number of round trips required to fetch data from database. For example,with Eager loading Busdetails will be loaded along with Busfeatures.

How will you implement Eager Loading?


Eager loading can be implemented by EF core using "Include" method and "ThenInclude" method.
For example,

                using (var context=new AppDBContext())
                {
                var fullbusdetailsalongwithfeatures=context.busdetails.include(f=>f.busfeatures).ToList();
                foreach(var features in fullbusdetailsalongwithfeatures)
                {
                console.writeline($"busname{features.busname}";Feature:{features.busfeature})
                }
                }

Include Method: The include method allows you to specify which navigation properties to load.
thenInclude Method: it enables you to include further related entities.
Advantages of Eager Loading:
Improved Performance:
it reduces number of database round trips required to fetch data.
Minimize Network Traffic:- Instead of sending multiple request to database for fetching related entities, you can fetch all in single query.