Verification on one or more entities fails. For more information, see the "EntityValidationErrors" attribute ., Detailed steps for opening a physical store
The cause of the problem: a field in the database table cannot be blank. When modifying object attributes, the field in the table corresponding to the object cannot be null.
Details:
Database:
C #:
Error code:
static void EditAdvance() { Category c = new Category() { CategoryID = 11,Description = "bad" }; System.Data.Entity.Infrastructure.DbEntityEntry<Category> a = db.Entry<Category>(c); a.State = System.Data.EntityState.Unchanged; a.Property("Description").IsModified = true; db.SaveChanges(); Console.WriteLine("modify success"); }
Correct code:
static void EditAdvance() { Category c = new Category() { CategoryID = 11, CategoryName="new",Description = "bad" }; System.Data.Entity.Infrastructure.DbEntityEntry<Category> a = db.Entry<Category>(c); a.State = System.Data.EntityState.Unchanged; a.Property("Description").IsModified = true; db.SaveChanges(); Console.WriteLine("modify success"); }