public void Update(HiFiveRecord item) { var itemToUpdate = _context.HiFiveRecords .SingleOrDefault(hiFive => hiFive.HiFiver == item.HiFiver); if (itemToUpdate != null) { // update fields here _context.SaveChanges(); } }
public void AddOrUpdate(HiFiveRecord item) { // Old post, but AddOrUpdate should only be used // in migrations, according to this: // http://thedatafarm.com/data-access/take-care-with-ef-4-3-addorupdate-method/ if (Find(item.HiFiver) == null) { _context.HiFiveRecords.Add(item); } else { Update(item); } _context.SaveChanges(); }