private void AddOrUpdateForm <T>(DataGridView dataGridView, Form form) where T : class { var result = form.ShowDialog(); // form has closed if (result == DialogResult.OK) { // reload the db and update the gridview if (form.Tag != null) { int id = (int)form.Tag; T entity = context.Set <T>().Find(id); context.Entry <T>(entity).Reload(); } else { dataGridView.DataSource = SetBindingList <T>(); } dataGridView.Refresh(); // ALWAYS update the customer orders report, hence use of AsNoTracking() LoadRegistrationView(); } }