I am trying to update 2 tables: RESTAURANT and HOURS. The tables shere the REST_ID key. I get an error on the line with the arrow (==>): Sorry, I'm trying to teach myself this stuff and it's the first time I've tried a multi-table insert.
The object could not be added or attached because its EntityReference has an EntityKey property value that does not match the EntityKey for this object.
RESTAURANT addRest = new RESTAURANT();
addRest.REST_NAME = r_name;
addRest.REST_STREET1 = r_street;
addRest.CITY_ID = c_id;
addRest.REST_PHONE = r_phone;
addRest.REST_WEBSITE = r_web;
addRest.HOUR = new HOUR();
addRest.HOUR.HOURS_SUN = h_su;
addRest.HOUR.HOURS_MON = h_mo;
addRest.HOUR.HOURS_TUE = h_tu;
addRest.HOUR.HOURS_WED = h_we;
addRest.HOUR.HOURS_THU = h_th;
addRest.HOUR.HOURS_FRI = h_fr;
addRest.HOUR.HOURS_SAT = h_sa;
addRest.HOURReference.EntityKey = new EntityKey("FVTCEntities.HOURS", "HOURS", 1);
==> db.AddToRESTAURANTs(addRest);
db.SaveChanges();