Cascade delete disabled, but cascading deletes still happen on Master/Detail Datagrid page

Hi, I have an app, where I have disabled (cleared the check box) for cascade delete, when the data was inferred. One page was built using the Master/Detail DataGrid template. On this page, if a master row is deleted, it also deletes the dependent detail rows and any other data that was dependent on the detail rows. Is it possible to prevent this, and have the delete on the master row fail, if dependent detail lines exist, when the cascade delete option is not enabled? On another page, which was built from the DataGrid InLine Edit template, the delete fails if there are any dependent rows from any other tables in the database. That is the behavior I expect. It seems the unexpected deletion of dependent data is only happening on the Master/Detail DataGrid page. I expected that the only time a master row could be deleted is when there are not dependent detail lines.

The EF will cascade delete when you have Include() in the query. Here is how the service delete method looks like:

In Master/Detail OrderDetails property of the Order instance will be populated and that's why delete will cascade. What you can do is to set OrderDetails to null just before the delete operation:

1 Like

Thank-you for your reply! Setting the data for the dependent detail rows to null did not work for me. It appears the delete method is going directly to the database to determine rows to be deleted, instead of using the data in the grid. I have decided to disabled the delete function for this app. If the user enters incorrect master data, the app will allow them to set a status on the row, which gets filtered out when the master grid is reloaded.