SCMQuoteParityEntry data = null; data= scmConetxt.SCMQuoteParityEntry.Where(i => i.Id == id).SingleOrDefault(); SCMQuoteParity scm = new SCMQuoteParity() { Id=Convert.ToInt32( data.SCMQuoteParityId)}; scmConetxt.SCMQuoteParity.Remove(scm); scmConetxt.SCMQuoteParityEntry.Remove(scmConetxt.SCMQuoteParityEntry.Find(id)); scmConetxt.SaveChanges();
代码如上,我想点击删除同时删掉两个表里的数据,两个表有字段关联。上面的代码报错
The object cannot be deleted because it was not found in the ObjectStateManager.
小白求救没怎么接触过ef
暮色呼如
相关分类