asp.net - Using Navigation properties? -



asp.net - Using Navigation properties? -

im trying set foreign key with

protected void adresdetailsview_iteminserting(object sender, detailsviewinserteventargs e) { var id = convert.toint32(customerdropdownlist.selectedvalue); e.values["customer_id"] = id; }

this not work because entity (adres) not have property customer_id. customer_id column name in database , should utilize client property wich navigation property. dont know how to.

i'm using ef 4.5

the simplest way modify navigation properties utilize foreign key properties. allow class have both customer , customerid/customer_id/whatever want property, kept synchronized. can update client id way you're trying now. however, don't specify version of ef using, , older versions not back upwards foreign key properties.

if foreign key properties not option, need create sure client id id exists in context. var client = context.customers.singleordefault(c => c.id == id); can set customer property specific customer.

asp.net entity-framework foreign-key-relationship

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -