Cascade delete

When deleting a record it deletes all dependents even though I have not set cascade delete in the database, this for business applications is bad and can completely break your application, is there any configuration where I can disable this behavior?

I want the cascade delete to happen only if I configure it in the database.

We are using default EF Core cascade delete (parent entity delete with tracked child items loaded in memory) without any configuration and behaviour depends on your database. If your relations are optional (nullable foreign key) and you delete parent entity all child entities foreign keys will be set to null. If your relations are required loaded in memory child entities will be deleted. More info can be found here:

Hi @enchev

For cascade delete does not occur I have to do:

  • add the file to ignore list
  • modify the controller of the respective file

This in a database with more than 200 tables is a great waste of time,
this could be solved with a configuration, where the line I commented was not generated
//.Include(i => i.Produtos)

I took some prints of ideas that greatly facilitate development so that we focus more on
the business rules of the application than on silly things

This can also be done through settings, anyone who wants to use just enable the configuration

== Always confirm before delete ==
to prevent the user from deleting a record by mistake

== Always show inner execptions messages ==
to really know what is happening when some error occurs in the database

== Always show message after save ==
to always inform the user that the record was actually saved in the database

They are simple things but they make a big difference in the development

Yes, we can expose a setting to control if related entities should be included in delete or not. It will be part of our release early next week.

@enchev Thank you, you are the best.

Was this implemented? I have a scenario where some tables I would like cascade delete and some not. I have a relationship setup in SQL with no action set in the delete rule in the SQL relationship yet the app has cascade deleted because the field is required. I can't see where to restrict the delete.



I'd watched that video but I'm afraid it doesn't help me.

I would like to cascade delete items like orders / order details. However, in the case of my other example, buildings / stock location, I would not want to delete stock locations when a building is deleted.


So you have relations where you want to cascade delete and relations where you do not want? At the moment this cannot be specified in Radzen UI however we will do our best to provide it as soon as we can. If you turn off cascade deletes in Radzen you can configure everything in your database.

Thanks for clearing that up. :slight_smile: