The DELETE statement conflicted with the REFERENCE constraint 'FKSalesOrderHeaderAddressShipToAddressID'. The conflict occurred in database 'AdventureWorks2012', table 'Sales.SalesOrderHeader', column 'ShipToAddressID'. The statement has been terminated. Is this actually a good way to delete items and the according entries in the other tables? DELETE statement conflicted with the REFERENCE constraint. But this cleanup needs to work. Which means that I probably have to extend the cleanup script so that it first identifies the records that should be deleted from STOCKITEMS, but can't because the corresponding ID is referenced from inside INVENTORYITEMS.
You need to flip your Remove methods around. You are deleting the parent first when there is still a child. You need to first delete the row from tbl8updatetransaction and then holidaydatetable. Tbl8updatetransactions tbl8updatetransaction = db.tbl8updatetransactions.Find(id);db.tbl8updatetransactions.Remove(tbl8updatetransaction);db.SaveChanges;HOLIDAYDATETABLE holidaydatetable = db.HOLIDAYDATETABLE.Find(id);db.HOLIDAYDATETABLE.Remove(holidaydatetable);db.SaveChanges.