I have an issue where I have a web app using Entity Framework connected to a SQL Server database. At random intervals, the data in one of my tables keeps getting cleared down. About 90% of the data is deleted.
We have scoured through the web app and cannot find any delete statements at all let alone one on that table.
We have had SQL Server Profiler running but this has not picked up any delete statements. However, I also have an ON DELETE trigger on this table to copy deleted data to a back up table and this runs and triggers fine so there seems to be a conflict on whether delete statements have actually been run or not. There is also hundreds of GB of space on the server so lack of space isnt an issue.
We have investigated as much as we can to no avail and we are now out of ideas.
Therefore if anyone knows of any reason this could happen i would be very thankful for any help.
Thanks in advance.
You should check if there are any cascade delete is on. This query can help you with that :
SELECT name,
delete_referential_action_desc
FROM sys.foreign_keys
I dont know if entity framework can have its own cascade delete, I dont use it. So I dont know how to check entity framework for cascade deletes.