how to use Foreign key in L2E or EF?
Posted
by 5YrsLaterDBA
on Stack Overflow
See other posts from Stack Overflow
or by 5YrsLaterDBA
Published on 2010-04-13T18:52:33Z
Indexed on
2010/04/13
18:53 UTC
Read the original article
Hit count: 567
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 Users 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.
anybody can help me?
© Stack Overflow or respective owner