---
title: Meta-class references
slug: commerce-connect-15/docs/meta-class-references
docTags: 
createdAt: 2026-07-30T20:34:45.000Z
---

You can create the following types of references:

- **1-N** reference
- **N-N** reference (bridge)
- **Aggregation** reference

:::hint{type="info"}
**Note**
When you create meta-class references, remember that you can only modify a meta-model in **Design** mode. See the [MetaClassManager class](docId\:NP7et4GlIKzHCSUK2aXTB) section.
:::

## Create a 1-N reference

The **1-N reference** type creates a reference between two meta-classes.

:::hint{type="info"}
**Note**
If you want to create a reference to this meta-class, define the `TitleFieldName` property of the `MetaClass` class with the correct string field name.
:::

The following example shows how to create a reference between the two meta-classes called *Project* and *Task*.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/waSqjy4Ysojn16R_uEXJn-20260723-164629.png)

To create a reference to the parent meta-class, call the `CreateReference` method of the `MetaClass` class, passing parent meta-class, reference name, friendly name, and is nullable flag.

**Example:** Creating a reference between Project and Task:

```csharp
// Open the meta-model edit scope
using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit())
  {
    // Create reference
    DataContext.Current.GetMetaClass("Task").CreateReference(DataContext.Current.GetMetaClass("Project"), "Project", "Project", true)):
    // Save Changes
    scope.SaveChanges();
  }
```

The `CreateReference` method adds two fields to the meta-class:

- `Reference Id` – Reference on the parent primary key, named `[ReferenceName]Id`, which is used to get/set the reference to the parent object.
- `Reference Title` – A read-only referenced field property to the parent title, named `[ReferenceName]`, which is used to get the title of the parent object.

When you update `Reference Id`, `Reference Title` is automatically updated.

:::hint{type="info"}
**Note**
You can create more than one reference between two meta-classes.
:::

### Create a reference field

After creating a reference, add any field from the parent meta-class as `Reference` field.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/7rE4F8Er6QLlivtX3t7Lm-20260723-164629.png)

Referenced fields are read-only. If a reference is not set, the reference field returns null. When you update `Reference Id,` `Reference Title` is automatically updated.

To add a referenced field to a meta-class, call the `CreateReferencedField` method of the `MetaClass` class, passing the reference field to the parent meta-class, and the parent field and field name.

### Create a back reference

After creating a reference in the parent meta-class, you can create a **Back reference** field on an existing reference. The back reference field returns a collection of child objects that has a reference to the current object.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/NE1pyQcIM1Eqqw_3PDJ1L-20260723-164629.png)

To add a back reference field, call the `CreateBackReference` method of the `MetaClass` class, passing reference field and field name.

## Create an N-N reference

The **N-N reference** type is also called a *bridge*, which is a meta-class with two references on class #1 and class #2.

:::hint{type="info"}
**Note**
Remember to define the `TitleFieldName` property of the `MetaClass` class in *both* meta-classes.
:::

The following example shows how to create a bridge between the two meta-classes *Project* and *Union*.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/0aaBd3w0xK_eC8NP_g7Z8-20260723-164629.png)

Call the `CreateBridge` method of the `MetaClassManager` class, passing class #1 and class #2 to create a bridge between the two meta-classes. The bridge meta-class is visible in the meta-class collection like the original meta-class, but has an `IsBridge` property with the value `true`. You can add a meta-field or delete a bridge meta-class like any other meta-class.

## Create an aggregation reference

An *aggregation* is slightly more complex than a reference. You typically use it to enable the parent entity object that has a collection of child entity objects, where one element is marked as default. The default children entity object is loaded when the parent object is loaded, and will be available from the property. The properties of children entity objects can be modified and are saved when you save the parent object. If you delete a parent object, all aggregated objects are automatically removed.

:::hint{type="info"}
**Note**
If you want to create an aggregation reference to this meta-class, be careful to define the `TitleFieldName` property of the `MetaClass` class with the correct string field name.
:::

The following example shows the `Client` and `Address` meta-classes, where the `Client` meta-class aggregates the `Address` meta-class. The client has many addresses but one is marked as **default**, and is available from the `Client.Address` property. The `Address` property returns an entity object, and you can update the default address properties as client properties. When you save `Client`, the default `Address` is automatically saved.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/6SWDGtAZpFm9Reb1fJ4aG-20260723-164629.png)

To add an aggregation to a meta-class, call the `CreateAggregation` method of the `MetaClass` class, passing the children meta-class. `CreateAggregation` adds a new meta-field to a parent meta-class, which can set and update an aggregated object.

**Example:** Creating an aggregated reference:

```csharp
public MetaField CreateAggregation(string name,
  string friendlyName,
  string childMetaClassName,
  string elementContainerRefFieldFriendlyName,
  string defaultElementFieldFriendlyName) {
  MetaField retVal = this.MetaClass.CreateAggregation(childMetaClassName,
    name,
    friendlyName,
    elementContainerRefFieldFriendlyName,
    defaultElementFieldFriendlyName);
  return retVal;
}
```
