Renaming ForeignKeys of a TrackedList table

3 posts, 0 answers
  1. Carsten
    Carsten avatar
    9 posts
    Member since:
    Sep 2008

    Posted 05 May 2011 Link to this post

    Hello,

    we have a problem with the automatically generated names of the foreign keys of a join table created for a TrackedList.

    Due to a large number of these tables with similar names OpenAccess generates names for the fk contrains by shortening the tablename.
    Sometimes to identical names are generated and will be made unique by adding an integer to the name.
    Up to this point everything is ok.

    The problem is, when a new table with a similar name is added to the database and the schemahandler generates the update script where some of the fk names are already used in the database.

    So i started to add names to the mapping file.

    But i'm not able to modify the name of the foreign key of the id2 column. I have only figured out how to change the foreign key name of the id column (db-owner-ref).

    <field name="testList">
      <collection>
        <extension key="db-link-table">
          <extension key="db-table-name" value="testList_name" />
          <extension key="db-primary-key">
            <extension key="db-constraint" value="pk_testList" />
          </extension>
          <extension key="db-owner-ref">
            <extension key="db-constraint" value="pk_testList_test" />
          </extension>
        </extension>
        <extension key="ordered" value="true" />
      </collection>
    </field>

    The question is how to change the name of the other foreign key?

    Greetings

    Carsten
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 06 May 2011 Link to this post

    Hi Carsten,

    to modify the name of your foreign-key column, you have to add an db-value extension to your mapping.

    Here is what I would suggest.

    <field name="testList">
      <collection>
        <extension key="db-link-table">
          <extension key="db-table-name" value="testList_name" />
          <extension key="db-primary-key">
            <extension key="db-constraint" value="pk_testList" />
          </extension>
    <extension key="db-value">
                        <extension key="db-constraint" value="YourConstraintName" />
    </extension>
          <extension key="db-owner-ref">
            <extension key="db-constraint" value="pk_testList_test" />
          </extension>
        </extension>
        <extension key="ordered" value="true" />
      </collection>
    </field>


    Greetings,
    Ralph
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  3. DevCraft banner
  4. Carsten
    Carsten avatar
    9 posts
    Member since:
    Sep 2008

    Posted 10 May 2011 Link to this post

    Hi Ralph,

    thank you! That is the solution.

    I must be blind to overlook the "db-value" key. :-)

    Greetings

    Carsten
Back to Top