c# - In what scenarios do I need foreign keys AND navigation properties in entity framework -
c# - In what scenarios do I need foreign keys AND navigation properties in entity framework -
my order class has:
public int customerid { get; set; } public client customer { get; set; }
do need both properties create relation working?
i not using disconnected entities, using code first approach.
according julia lerman's book: programming entity framework: dbcontext, difference lies @ difficulty of updating navigation property. in page 85, suggests "if there 1 thing can create life easier in n-tier scenarios, it’s expose foreign key properties relationships in model." book includes samples both scenarios.
the reason including foreign key property tells entity framework utilize foreign key association, simpler using so-called independent association when need update relationship, i.e., changing order 1 client in example. foreign key association, need changing customerid. without customerid foreign key, need more steps. independent association uses objectstatemanager explained code first: independent associations vs. foreign key associations? objectstatemanager complex , not exposed dbcontext api.
c# entity-framework ef-code-first foreign-keys entity-framework-5
Comments
Post a Comment