private void DeleteEmployee() { using (var db = new EmployeeContext()) { foreach (var item in db.Employees.ToList()) { Console.WriteLine(item); } // Employee choosen to delete Employee deletedEmployee = null; long response; // EmployeeToDelete contient l'instance à supprimer do { Console.WriteLine("Choose the id employee you want to delete"); long.TryParse(Console.ReadLine(), out response); deletedEmployee = db.Employees.Find(response); } while (deletedEmployee == null); // sure ? int?choice; do { choice = MenuUtils.GetIntChoice(MenuUtils.deletedEmployeeChoice(), 1, 3); switch (choice) { case 1: // delete db.Entry(deletedEmployee).State = EntityState.Deleted; break; case 2: DeleteEmployee(); break; case 3: CUDEmployee(); break; } } while (choice != 1 || choice != 2 || choice != 3); db.SaveChanges(); } }