猿问

EntityFramework 如何更新 detached 实体

如题,EntityFramework 如何更新 detached 实体,如下代码不能更新:


Product p = null;
using (EFDbContext context = new EFDbContext()) {
   p = context.Products.First();
}
using (EFDbContext context = new EFDbContext()) {
   p.Remark = "aaa";
   context.SaveChanges(); //不能更新
}



开心每一天1111
浏览 710回答 1
1回答
随时随地看视频慕课网APP
我要回答