private void MenuItemDeleteStoragePlace_OnClick(object sender, RoutedEventArgs e) { var storagePlace = (StoragePlace)StoragePlaceComboBox.SelectedItem; try { ApplicationDbContext.Instance.StoragePlaces.Remove(storagePlace); ApplicationDbContext.Instance.SaveChanges(); StoragePlaces.Remove(storagePlace); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { MessageBox.Show("To miejsce przechowywania jest przypisane do jakiejś książki, nie można go usunąć.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } }