私は次のものを持っています:
if (chemexist == false) // conditionally creating WtrChem record
{
WtrChem wc = new WtrChem();
wc.Contact = "John Smith";
..
wc.Phone = ("800-888-9988");
Db.WtrChem.Add(wc);
Db.SaveChanges();
}
WtrChemDetail psw = new WtrChemDetail (); // creating details record for WtrChem
psw.Comments = comment;
..
..
Db.WtrChemDetail.Add(psw);
Db.SaveChanges();
コードは最初にマスターレコードを作成し、次に詳細レコードを作成します。私が持っているものは機能します。ベストプラクティスの観点から、上記のことを行うためのより効率的な方法があるかどうか疑問に思っています。