in

The ORM Foundation

Get the facts!

How to change on update action on foreign key

Last post 08-23-2011 6:20 by lozdown. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-02-2011 12:53

    • szubia
    • Top 200 Contributor
    • Joined on 05-02-2011
    • Posts 2

    How to change on update action on foreign key

    I have a foreign key that has the ON DELETE NO ACTION ON UPDATE NO ACTION and I'd like the UPDATE to be CASCADE instead of NO ACTION. I know I can change the script manually to reflect that but I was wondering if there is any way to change that in the diagram. Thanks
  • 05-02-2011 15:43 In reply to

    Re: How to change on update action on foreign key

    Can you provide a little more information.?

    Are you talking about an object-role model diagram?

    Ken

  • 05-02-2011 16:38 In reply to

    • szubia
    • Top 200 Contributor
    • Joined on 05-02-2011
    • Posts 2

    Re: How to change on update action on foreign key

    Yes I'd like to make a change in the ORM(object-role model) diagram so that when I generate the SQL scripts it shows ON UPDATE CASCADE instead of ON UPDATE NO ACTION for the foreign key. Thanks
  • 05-03-2011 21:08 In reply to

    Re: How to change on update action on foreign key

    There is currently no way to do this in the UI of the tool. However, the schema elements for generating different update and delete actions are part of the generators and should generate could correct SQL if they are set, but there is currently no way to direct the generator to make this change.

    It should be possible to add markup similar to the custom-properties based solution for adding schema names shown in http://www.ormfoundation.org/forums/p/573/1706.aspx#1706. The main difference would be that tracing a reference constraint back to a specific role that could hold the custom property. Due to absorption and the possibility of multiple steps in ORM space corresponding to a single reference at the relational level, the traceback from a generated reference constraint to a role is not quite as trivial as matching a generated table to an object type. However, I should be able to get something that works for the majority of cases.

    Give me a few days and I'll try to fit in the xslt exercise to enable a custom property that will control this generated SQL directive. In the meantime, if you want to change the overall default, look for 'onUpdate=' in C:\Program Files\Common Files\Neumont\DIL\Transforms\DCILtoDDIL.xslt and change the default for onUpdate (and onDelete) to one of the values in the referentialAction enum in C:\Program Files\Common Files\Neumont\DIL\Schemas\DDIL.xsd. The xslt changes should apply immediately if you re-run the custom tool ('Run Custom Tool' is on the context menu of the .orm file in the Solution Explorer window).

    -Matt

  • 05-04-2011 3:27 In reply to

    Re: How to change on update action on foreign key

    Don't forget that SQL Server doesn't allow multiple cascade paths to the same table, so you can't just blindly use cascade everywhere and expect the schema to work. Unless that's fixed in a recent SQL Server version?
  • 08-23-2011 6:20 In reply to

    • lozdown
    • Top 75 Contributor
      Male
    • Joined on 06-06-2011
    • Rugby
    • Posts 7

    Re: How to change on update action on foreign key

    I also want to control the generation of different cascade update/delete actions in SQLServer. I've followed through the use of custom properties and can see how this might be used. Did you create an xslt transform as you suggested in your post? If so could I make use of it? Thanks Laurie
Page 1 of 1 (6 items)
© 2008-2014 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service