Lazy-loading in Entity Framework is turned on by default. You cannot force something to be 'lazily-loaded'. All you can do is turn off lazy-loading (which by the way, isn't actually eager-loading, it's 'no-loading'). So the answer is you can't. Indeed, however, as the comments have pointed out, if Owners
class has a navigation property like, for instance,
public class Owners{
public string UNQ4 {get;set;}
public virtual OtherClass NavigationProperty {get;set;}
}
Then the NavigationProperty
property will have a value of null
initially when you do a query such as var owners = _db.Owners.First()
. Later, when your program makes a call to owners
accessing its NavigationProperty
(like owners.NavigationProperty.Name
), only then will a trip to the database be made to get the related NavigationProperty
data.
Lazy-loading effectively does not load navigation properties until/if they are required. Good reference: https://msdn.microsoft.com/en-us/library/jj574232(v=vs.113).aspx