public void Save(tbKaryawan dbItem) { if (dbItem.id == 0) //create { context.tbKaryawans.Add(dbItem); } else //edit { var entry = context.Entry(dbItem); entry.State = EntityState.Modified; } context.SaveChanges(); }