I am trying to 'delete' a record from a table in my view (not my database)... and I am receiving:
An exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occured in EntityFramework.dll but was not handled in user code.
I have debugged, and the record that is going through the DeleteConfirmed
Actionresult is correct, and all of the properties/fields are filled in, not one is left blank.
Controller Action:
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
codePerson codePerson = db.codePerson.Find(id);
codePerson.deleted = true;
TryUpdateModel(codePerson);
db.SaveChanges();
return RedirectToAction("Index");
}
MetaData Class:
[MetadataType(typeof(MetaDatacodePerson))]
public partial class codePerson
{
}
public class MetaDatacodePerson
{
public int ID { get; set; }
[RegularExpression(@"^(\s+)?[\w.\\]+\s\w+\s\w+(\s+)?$", ErrorMessage = "Custom Error Message")]
public string Name { get; set; }
public string IBM { get; set; }
public string CategoryID { get; set; }
public bool deleted { get; set; }
public int LocationID { get; set; }
}
Why is this error occuring when all of the properties of codePerson
are being populated? All of these fields in my database do not accept nulls, and like I said above.. when debugging none of these fields are null, or emptyspace.