How to avoid lazy loading when accessing the property of the foreign key identifier through the navigation property?

I am going to convert a project from NHibernate to Entity Framework 6.

Given this simple model:

public class User
{
    public int ID { get; set; }
    public string FullName { get; set; }
    public virtual Organization Organization { get; set; }
    // [...]
}

public class Organization
{
    public int ID { get; set; }
    public string Name { get; set; }
    public virtual List<User> Users { get; set; }
    // [...]
}

Access to the primary key (identifier) โ€‹โ€‹through the Organization's navigation property will load the entire organization object in context:

foreach(var user in db.Users)
    Console.WriteLine(user.Organization.ID);

Given that the OrganizationID foreign key is part of the User string, I should have access to it without invoking the Lazy Load of the whole entity (and, indeed, NHibernate does it right).

With the exception of adding properties for foreign key identifiers to all of my 100+ objects, so I can access their values โ€‹โ€‹without loading objects, is there anything to avoid this behavior?

EDIT: , Organization ( NHibernate):

foreach(var user in db.Users)
    Console.WriteLine(user.Organization != null);

, , - . ... - ?

+4
1

, ( , , ), , .

public class User
{
    public int ID { get; set; }
    public string FullName { get; set; }

    //added ID    
    public int OrganizationID { get; set; }
    public virtual Organization Organization { get; set; }
    // [...]
}

int, , EF ID . : 100+ ...: |

UPDATE:

; :

db.Users
        .Include("Organization.ID")
        .Where(/*your stuff*/) //etc.;

, . , .

+1

All Articles