---
title: "Implement components to store migrated data"
slug: "implement-components-to-store-migrated-data"
abstract: "How to create and deploy the facet and model components needed to store migrated data using xDB Migration Tool."
---
# Implement components to store migrated data

> [!note]
> The xConnect developer documentation provides detailed instructions on how to build the following components.

<details>
<summary><h2>Create facet</h2></summary>

A facet is needed to store the customer loyalty program information for a specific contact.

```csharp
using Sitecore.XConnect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MigrationTool.Examples.Loyalty
{
    [FacetKey(DefaultFacetKey)]
    public class LoyaltyProgramInfo : Facet
    {
        public const string DefaultFacetKey = "LoyaltyProgram";

        public LoyaltyProgramInfo()
        {
        }

        public int MembershipId { get; set; }

        public DateTime EnrollmentDate { get; set; }

        public string HomeStoreId { get; set; }
    }
}
```

</details>

<details>
<summary><h2>Create model</h2></summary>

A custom model is needed to notify xConnect that the custom facet is available to contacts in xDB.

```csharp
using Sitecore.DataExchange.Tools.XdbDataMigration.Models;
using Sitecore.XConnect;
using Sitecore.XConnect.Schema;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MigrationTool.Examples.Loyalty
{
    public class CustomMigrationModel
    {
        public static XdbModel Model { get; } = BuildModel();

        private static XdbModel BuildModel()
        {
            var modelVersion = new XdbModelVersion(1, 0);
            var builder = new XdbModelBuilder("MigrationTool.Examples.CustomMigrationModel", modelVersion);
            builder.ReferenceModel(DataMigrationCollectionModel.Model);
            builder.DefineFacet<Contact, LoyaltyProgramInfo>(LoyaltyProgramInfo.DefaultFacetKey);
            return builder.BuildModel();
        }
    }
}
```

</details>

<details>
<summary><h2>Deploy components to the Sitecore server</h2></summary>

Build the project and deploy the assembly to your Sitecore server.

</details>

<details>
<summary><h2>Register model with Data Exchange Framework</h2></summary>

Registering the model with Data Exchange Framework (DEF) makes it easier to incorporate the model into the data migration process.

1. In Content Editor, navigate to **system > Settings > Data Exchange > Providers > xConnect > Collection Models > xDB Data Migration Tool**
2. Add the following item:

|     |     |
| --- | --- |
| Template | **Compiled Collection Model** |
| Item name | **Custom Migration Model** |

- Set the following field values:

| Field | Value |
| --- | --- |
| Collection Model Type | `MigrationTool.Examples.Loyalty.CustomMigrationModel,MigrationTool.Examples.Loyalty` |

1. Save the item.
2. Navigate to **Facets**. There should be two child items: **Contact** and **Interaction**.

![Contact and Interaction nodes in the Content tree.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/dmt/50/xdb-data-migration-tool/images/child-items-under-facets-item.png)

> [!note]
> If no items appear under the **Facets** item, clear the cache for the `master` database, then refresh the **Facets** item.

- Navigate to **Contact > LoyaltyProgram**. There should be a child item for each of the properties you defined in the facet.

![Loyaltyprogram facet in the Contact node in the Content tree.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/dmt/50/xdb-data-migration-tool/images/child-items-under-loyaltyprogram-item.png)

</details>

<details>
<summary><h2>Deploy model to xConnect</h2></summary>

1. Navigate to the item **Custom Migration Model**.
2. On the toolbar, click **Convert Model to JSON**.

![Convert Model to JSON button in the menu ribbon.](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/dmt/50/xdb-data-migration-tool/images/convert%20model%20to%20json%20button.png>)

1. Your browser will download a JSON file.
2. Copy the JSON file to the following locations:

| Server | Path |
| --- | --- |
| xConnect | `Website\App_data\Models` |
| xConnect Search Indexer | `App_data\Models` |

</details>