Implement Components to Store Migrated Data

Note

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

Create facet

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

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.

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
  1. 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.
../../_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.

  1. Navigate to Contact > LoyaltyProgram. There should be a child item for each of the properties you defined in the facet.
../../_images/child-items-under-loyaltyprogram-item.png

Deploy model to xConnect

  1. Navigate to the item Custom Migration Model.
  2. In the toolbar, click Convert Model to JSON.
../../_images/convert-model-to-json-button.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