I am looking for a possible way to enable Lazy Loading in my DbContext but not all the time, only in specific instances when I need it. Because of issues like t
DbContext
You can use ChangeTracker.LazyLoadingEnabled property:
Gets or sets a value indicating whether navigation properties for tracked entities will be loaded on first access. The default value is true.
Gets or sets a value indicating whether navigation properties for tracked entities will be loaded on first access.
The default value is true.
e.g.
context.ChangeTracker.LazyLoadingEnabled = false; var query = context.Set<…>()...;