//we call this to save the changes when we're done public bool Save() { bool close = false; bool retval = true; MyDB db = _db; //remember we set _db in the constructor if (db == null) { db = new MyDB(); close = true; } try { // a reference to this row should have been saved in _foo if we loaded it from the db. // take a look at FooObjectFromFoo if (_foo == null) { _foo = db.Foos.SingleOrDefault(x => x.FooID == _FooID); } if (_foo == null) { _foo = new Foo(); } //copy all my object values back to the EF Object _foo.blah = blah; _foo.x = x; _foo.y = y; try { //save the new one. db.SaveChanges(); } catch (DbEntityValidationException dbEx) { TransactionResult.AddErrors(dbEx); retval = false; } } catch { throw new Exception("Something went wrong here."); } finally { if (close) { db.Dispose(); } } //if we created this connection then let's close it up. }