in

The ORM Foundation

Get the facts!

Changing the Names of Constraints in Generated SQL

Last post Thu, Oct 28 2010 17:59 by Anonymous. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • Tue, Oct 26 2010 13:53

    Changing the Names of Constraints in Generated SQL

    Is there a way to change the naming style so that, for instance, "FK_" is used as a prefix for the constraint name instead of as a suffix?

    Filed under: ,
  • Thu, Oct 28 2010 17:15 In reply to

    Re: Changing the Names of Constraints in Generated SQL

    Hi John,

    Unfortunately this is a known undone (see line 948 in http://orm.svn.sourceforge.net/viewvc/orm/trunk/RelationalModel/OialDcilBridge/NameGeneration.cs?revision=1459&content-type=text%2Fplain) which says // UNDONE: The PK, UC, FK suffixes should have generator options to control them.

    These names are combinations of table names, constraint names (generally used only if they are not the default 'Constraint#' pattern), the suffix, and possibly a trailing number. Other inputs (such as column names) could also be used. The proper fix here is to allow format string similar to the relational name reference mode formatters that would give you broad control over use of replacement fields.

    I don't think I'll get to this soon, but I'm attaching a stopgap that modifies the decorated constraint names at the XML level. Follow directions in the readme for installation and use. This is similar to the answer I gave you for http://www.ormfoundation.org/forums/p/581/1738.aspx#1738 (except I'm not leaving the transform as an exercise).

    -Matt

  • Thu, Oct 28 2010 17:59 In reply to

    Re: Changing the Names of Constraints in Generated SQL

    Thanks, Matt, I'll take a look at the workaround.

    BTW, when you mention "table names" above, did you mean the source and target table names? I suppose one might need a pattern like {source}_{sourcekeys}_{target}_{targetkeys}_FK. I've got one now that should be FK_BASEDATA_CAT1PERFORMANCEID_PERFORMANCE to distinguish from FK_BASEDATA_CAT2PERFORMANCEID_PERFORMANCE.

     

Page 1 of 1 (3 items)
© 2008-2024 ------- Terms of Service