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);
, , - . ... - ?