Lazy Loading

db.Configuration.LazyLoadingEnabled = true;
var student = db.Students.First();
// Loads Student address for the current Student (Executes seperate SQL query).
var address = student.StudentAddress;

Rules for Lazy Loading

  1. context.Configuration.ProxyCreationEnabled should be true.
  2. context.Configuration.LazyLoadingEnabled should be true.
  3. Complex property should be defined as virtual.

Turn lazy loading off for serialization

Turning off lazy loading for specific navigation properties

Turn off lazy loading for all entities