I've read through LOTS of posts on saving a detached entity in Entity Framework. All of them seem to apply to older versions of Entity Framework. They reference methods such as ApplyCurrentValues and ChangeObjectState which do not seem to exist. On a whim I decided to try a method I found through intellisense and I want to make sure this is the correct way to do this since I don't get to see what happening behind the scenes:
public void SaveOrder(Order order)
{
using (VirtualWebEntities db = new VirtualWebEntities())
{
db.Orders.Attach(order);
db.Entry(order).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
}
}
Is this the correct way to update an existing item that was changed?
See Question&Answers more detail:os