This is a migrated thread and some comments may be shown as answers.

Renaming ForeignKeys of a TrackedList table

2 Answers 37 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carsten
Top achievements
Rank 2
Carsten asked on 05 May 2011, 12:20 PM
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 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 06 May 2011, 09:10 PM
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.
0
Carsten
Top achievements
Rank 2
answered on 10 May 2011, 08:39 AM
Hi Ralph,

thank you! That is the solution.

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

Greetings

Carsten
Tags
Development (API, general questions)
Asked by
Carsten
Top achievements
Rank 2
Answers by
Ralph Waldenmaier
Telerik team
Carsten
Top achievements
Rank 2
Share this question
or