public Boolean DeleteProdotto(Prodotto prodotto) { Prodotto newProdotto = GetProdotto(prodotto.Id); if(newProdotto != null) { /// FIRST remove related entries in dettaglioListino DettaglioListinoService dlSrv = new DettaglioListinoService(); List<DettaglioListino> dettagli = dlSrv.GetDettagliByProdotto(prodotto.Id); foreach (var dettaglio in dettagli) { context.DettaglioListinoSet.Remove(dettaglio); } context.ProdottoSet.Remove(prodotto); context.SaveChanges(); return true; } else { return false; } }