1

During a save using a scaffolded MVC Controller I want to get the properties changed.

private myEntities db = new myEntities();

public ActionResult Edit()
if (ModelState.IsValid)
{
     tblQuote quote = db.Quotes
     .Include(a => a.Parts)
     .SingleOrDefault(x => x.QuoteID == 4);

     quote.Name = "NewName"

     db.Entry(quote).State = EntityState.Modified;

     db.SaveChanges();
}

I've attempted to use GetModifiedProperties from here Getting all changes made to an object in the Entity Framework

var myObjectState=db.ObjectStateManager.GetObjectStateEntry(quote);

But VS tells me db "Does not contain a definition for ObjectStateManager". How do I get the changed fields from "quote"

Joe Stellato
  • 558
  • 9
  • 31
  • Try using `var myObjectState = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry([object name])`. Let me know if it works. – Tetsuya Yamamoto Jun 16 '17 at 01:18

0 Answers0