2015年7月9日 星期四

新增 entity 且 savechanges 後馬上要取得關聯表格的資料會是null

直接 new 物件會有這問題
例如: var model=new 需求單();

請改為透過 Create 產生物件
例如: var model = db.需求單.Create();

沒有留言:

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...