Patient.DivHospitalID (FK)
DivHospital.HospitalID (FK)
Hospital.HospitalID (PK)
我需要插入DivHospital醫院並鏈接/插入患者DivHospital。實體框架插入多個外鍵
Patient tp = new Patient();
DivHospital dh = new DivHospital();
dh.HospitalReference.EntityKey =
new EntityKey("transportPagerEntities.Hospital", "hospitalID", hospital);
tp.DivHospitalReference.EntityKey = new
EntityKey("transportPagerEntities.DivHospital", "divHospitalID", hospitalref);
context.AddToDivHospital(dh);
context.AddToTransportPatient(tp);
context.SaveChanges();
和UR問題是什麼? – Nix 2010-08-10 13:50:04