I am trying to update a field with various related tables using the EntityState.Modified but SaveChanges() is not applying the changes. I am using postman to post to the localhost/8000/api/co/1 and the status says 202 accepted. My repository is returning the record but it is not modified at all.
Question What am I missing in my repository for the changes to take in affect? Do I need to set each property individually? (I have hundreds)
Most the examples I can find related to the repository pattern and the entity framework 7, only utilize the EntityState.Modified(), then save changes. Can someone please help me point out what I am missing? I have my other repositories working fine that create, delete and get working just fine
My Repository
public COMP Update(int id)
{
var original = _context.Complaints.Where(c => c.COMP_ID == id).FirstOrDefault<COMPLAINT>();
_context.Entry(original).State = EntityState.Modified;
SaveAll();
return original;
}
public bool SaveAll()
{
return _context.SaveChanges() > 0;
}