I want to update a single field in ASP.Net MVC 5 I get error:
My Code:
MyJobs.PublishStatus = 1;
db.MyJobContext.Attach(MyJobs);
db.Entry(MyJobs).Property(x => x.PublishStatus).IsModified = true;
//db.Configuration.ValidateOnSaveEnabled = false;
db.SaveChanges();
I get bellow error:
Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.
there is post regarding this error but I could not figure it out: Entity Framework: "Store update, insert, or delete statement affected an unexpected number of rows (0)."
and updating single field in asp.net MVC from: How to update only one field using Entity Framework?