Implement components to store migrated data

Version: 5.0
Note

The xConnect developer documentation provides detailed instructions on how to build the following components.

Create facet

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

RequestResponse
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; }
    }
}

Create model

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

RequestResponse
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();
        }
    }
}

Deploy components to the Sitecore server

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

Register model with Data Exchange Framework

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.
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.

Deploy model to xConnect

  1. Navigate to the item Custom Migration Model.

  2. In the toolbar, click Convert Model to JSON.

Convert Model to JSON button in the menu ribbon.
  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

Do you have some feedback for us?

If you have suggestions for improving this article,