I have a User
table which has a PrivilegeId
foreign key points to a Privilege
table and is the primary key there.
In Entity Framework, the VS will not generate a PrivilegeId
variable under User
for you. It will generate a Privilege
property and PrivilegeReference
property for you instead.
When I load a User
, the Privilege
property is null
by default. That means EF does not load refered entity for you automatically. I think I may did something wrong? I cannot load Privilege
separatedly because I have no info about the Privilege
at that time. I guess EF should load the refered entities for me but I missed something. I need the PrivilegeId
associated with my User
object.
anybody can help me?
EDIT:
another answer: What are Navigation Properties in Entity Framework for?