Compartir a través de


How to: Create an Association between Entities

You can define relationships between entities in your Business Data Connectivity (BDC) model by creating associations. Visual Studio generates methods that provide consumers of the model with information about each association. These methods can be consumed by SharePoint web parts, lists, or custom applications to display data relationships in a user interface (UI).

You can create two types of associations in the BDC designer: foreign key-based associations and foreign keyless associations. For more information, see Creating an Association Between Entities.

To create an association between entities

  1. On the BusinessDataConnectivity tab of the Toolbox, choose the Association item.

  2. On the BDC Designer, choose the source entity, and then choose the destination entity.

    The Association Editor appears.

  3. If you want to create a foreign key-based association, select the Is Foreign Key Association check box.

    1. In the Source ID column of the Identifier Mapping table, choose the identifier next to each matching type descriptor that appears in the Field column.

      For example, In the Source ID column, select ContactID next to the ReadList.salesOrderList.SalesOrderList.SalesOrder.ContactID type descriptor and the ReadItem.salesOrder.SalesOrder.ContactID type descriptor.

  4. If you want to create a foreign keyless association, clear the Is Foreign Key Association check box.

  5. Choose the OK button.

  6. On the BDC Designer, a line that represents the association appears between the source entity and the destination entity.

    Visual Studio adds an Association Navigator method to the service class of the destination entity and the service class of the source entity. For more information about Association Navigation methods, see Supported Operations.

  7. In the Association Navigator method of the source entity, add code that returns a collection of destination entities.

  8. In the Association Navigator method of the destination entity, add code that returns the related source entity.

    For examples of Association Navigator methods, see Creating an Association Between Entities.

See Also

Tasks

How to: Add a Finder Method

How to: Add a Specific Finder Method

How to: Add a Creator Method

How to: Add a Deleter Method

How to: Add an Updater Method

How to: Add a Parameter to a Method

How to: Define a Method Instance

How to: Define the Type Descriptor of a Parameter

Walkthrough: Creating an External List in SharePoint by Using Business Data

Concepts

Creating an Association Between Entities

BDC Model Design Tools Overview

Other Resources

Designing a Business Data Connectivity Model