Relationship and CascadeType

How come that I define a relationship in Data Modeler to be Cascade/Cascade and the resulting output is:


    [Association([TAssociationProp.Lazy, TAssociationProp.Required],
    CascadeTypeAll - [TCascadeType.Remove])]
    [JoinColumn('ID_Settings', [TColumnProp.Required], 'ID')]
    FSettings: Proxy<TSettings>;  

I would expect it to be [TCascadeType.SaveUpdate, TCascadeType.Merge, TCascadeType.Remove], but no matter what I try, it keeps generating the above with orphan records as a result.

Manually changing the resulting file is obviously not an option....

Rgds, Mark

Setting Cascade to All in the Associations tab of the TMS Aurelius Exporter, overrides the setting and results in:


   [Association([TAssociationProp.Lazy, TAssociationProp.Required], CascadeTypeAll)]
    [JoinColumn('ID_Settings', [TColumnProp.Required], 'ID')]
    FSettings: Proxy<TSettings>;  

This works and all child records are correctly deleted (if parent entity is deleted).

Why is this required?  Selecting Cascade in the Relationship Editor, leads me to think that this should not be required. Moreover, the override is not required for 1-M associations....

Regards,
Mark

Usually N:1 associations are not expected to be cascade deleted. Your settings could be used by more than one entity, and deleting it would cause a foreign key errors in other objects that still references it. The cascades are there by default, you can modify them using scripts:

https://download.tmssoftware.com/business/dmodeler/doc/web/adding-orderby-attribute-to-ma_2.html

Hi Wagner,


My thinking was wrong; the Settings are intended as 1:1 (each entity it's own settings) but you're correct that in reality it could be an N:1.

Instead of a script I manually set the override in the TMS Aurelius Exporter, which works for me.  I am now wondering whether orphaned Settings records could be the problem I had with Serializing/Deserializing (see https://www.tmssoftware.com/site/forum/forum_posts.asp?TID=15423&title=parent-id-field-not-set-when-deserializing).  I'll continue that discussion in the relevant support case.

Thanks,
Mark