The object cannot be deleted because it was not found in the ObjectStateManager

前端 未结 10 1202
终归单人心
终归单人心 2020-11-27 14:48

I am getting this error \"The object cannot be deleted because it was not found in the ObjectStateManager.\"

My code is:

    protected MyEntities sql         


        
10条回答
  •  离开以前
    2020-11-27 15:48

    In case none of the above worked, you may try this solution:

    context.Entry(yourObject).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges();

提交回复
热议问题