Emitting ManyValuedAssociation

What are the minimum Data Modeler and schema requirements (let's say for MSSQL) to emit the [ManyValuedAssociation] attribute for entity relationships exported by DM for Aurelius? 


I'd like to take advantage of the TAureluisDataset.DatasetField property thinking master-detail relationships will be automatically synchronized. I'm hoping this would eliminate the necessity of manually detecting row changes to the parent with a corresponding refresh to the child. The implementation in this particular scenario is using the classic TDataSource, TDBGrid, and TDBNavigator configuration.


Partial success...



I discovered the Many-Valued Associations option on DM's Aurelius export dialog. Specifically, I selected the parent table in the Mappings section, then enabled the MVA property for the child table located in the Many-Value Associations section. With this option enabled, the expected ManyValuedAssociation attribute was emitted thereby providing the anticipated master-detail code support I mentioned in my initial post.



I'm now noticing that it's necessary to manually assign the parent entity to the child's FK field in the dataset's BeforePost handler. If this isn't done, the native CheckRequiredFields method in Data.DB.pas triggers a "Field Required" exception (because the given FK field was never set and remains Null.) When this native check is bypassed (via debugging,) the process continues until SQL complains about a Null value in the child's FK column. This seems to indicate the FK is never set by the ORM. The child's FK column in this scenario is not permitted to be Null in the SQL schema.



The Data Modeler version is 2.3.0.0

If the ManyValuedAssociation is bidirectional (i.e, if you have a property "Parent" (or whatever) in the detail class pointing back to the master class), then you must set that property yourself. If the association is unidirectional, then Aurelius fills that field automatically for you.