---
title: "移行データを格納するコンポーネントを実装する"
slug: "implement-components-to-store-migrated-data"
abstract: "xDB Migration Toolを使って移行データを保存するために必要なファセットやモデルコンポーネントの作成と展開方法。"
---
# 移行データを格納するコンポーネントを実装する

> !注xConnect開発者ドキュメントには、以下のコンポーネントの構築方法について詳細な指示が記載されています。

## ファセットを作成する

特定の連絡先の顧客ロイヤルティプログラム情報を保存するためのファセットが必要です。

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; }
 }
}
## モデルを作成

カスタムファセットがxDBの連絡先に利用可能であることをxConnectに通知するためにはカスタムモデルが必要です。

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

## コンポーネントをSitecoreサーバーにデプロイする

プロジェクトを構築し、アセンブリをSitecoreサーバーにデプロイしてください。

## データ交換フレームワークを用いたレジスタモデル

モデルをData Exchange Framework(DEF)に登録することで、データ移行プロセスに組み込むのが容易になります。

1.  **コンテンツエディターで、システム>設定>データ交換プロバイダー > xConnect >コレクションモデル> xDBデータ移行ツール>に移動します**
2.  以下の項目を追加してください:

テンプレート

**コンパイルドコレクションモデル**

アイテム名

**カスタムマイグレーションモデル**

-   以下のフィールド値を設定します:

フィールド

価値

コレクションモデルタイプ

MigrationTool.Examples.Loyalty.CustomMigrationModel,MigrationTool.Examples.Loyalty

1.  アイテムを保存してください。
2.  **ファセット**にナビゲートしてください。子項目は2つあります:**接触**と**インタラクション**です。

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

> !注 **ファセット**項目の下にアイテムが表示されない場合は、masterデータベースのキャッシュをクリアし、**その後ファセット** アイテムを更新してください。

-   **LoyaltyProgram >お問い合わせ**へ移動してください。ファセットで定義した各プロパティに対応する子項目があるはずです。

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

## モデルをxConnectにデプロイしてください

1.  「 **カスタム移行モデル**」という項目に移動します。
2.  ツールバーで「 **モデルをJSONに変換**」をクリックします。

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

1.  ブラウザはJSONファイルをダウンロードします。
2.  JSONファイルを以下の場所にコピーしてください:

サーバー

経路

xConnect

Website\\App\_data\\Models

xConnect Search インデクサー

App\_data\\Models