Data Access has been discontinued. Please refer to this page for more information.

How to: Control the Reference Property Name

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This article will show you how to control the names of generated reference navigation properties in the child class in a 1:m association.

The name of the reference navigation property can be based on:

Based on the name of the parent class in the association

By default reference navigation property names are based on the name of the parent class in the association. For the example, consider the schema of the Package-Location database:

  1. Create a new Telerik Data Access Class Library project.
  2. Choose the Populate from database option and click the Next button.
  3. Select the Package-Location database at the Setup Database Connection screen and click the Next button.
  4. At the Choose Database Items screen select both the Location and Package tables and click the Next button.
  5. At the Define Naming Rules screen choose the Navigations tab. Notice that the Base Reference Name On setting is set to Class.

  6. Click the Finish button to complete the wizard. The resulting Domain Model should look like this:

Notice the two reference navigation property of the Package class - Location has its name based on the name of the parent class Location.

Based on the name of the foreign key property of the child class in the association

Now consider a scenario where the database schema has a second relationship:

In such scenario, if the names of the generated reference navigation properties are based on the name of the parent class, they will become ambiguous - Location and Location1:

To prevent that you can instead use the name of the foreign key property of the child class by following the next steps.

  1. Create a new Telerik Data Access Class Library project.
  2. Choose the Populate from database option and click the Next button.
  3. Select the Package-Location database at the Setup Database Connection screen and click the Next button.
  4. At the Choose Database Items screen select both the Location and Package tables and click the Next button.
  5. At the Define Naming Rules screen choose the Navigations tab. Set the Base Reference Name On setting to Foreign Key Property. To achieve higher clarity of the resulting names, use Remove Suffix(es) from Foreign Key to remove the Id suffix.

  6. Click the Finish button to complete the wizard. The resulting Domain Model should look like this:

We recommend you uncheck the Apply Property Naming Rules on the Reference Side checkbox when you are basing the names of the reference properties on the foreign key property.

The two reference navigation properties of the Package class are now named SourceLocation and DestinationLocation - based on the respective foreign key properties for the association - SourceLocationId and DestinationLocationId respectively.

As you may have noticed in the current case, the names of the collection navigation properties in the parent class Location have become ambiguous - Packages and Packages1. To see how to modify them, please refer to How to: Control the Collection Property Name