# Migrate related data

1. From the folder in which you cloned the Related data migration GitHub sample, copy the following files:
   * *RelatedDataMigration.aspx*
   * *RelatedDataMigration.aspx.cs*
   * *RelatedDataMigration.aspx.designer.cs*

2. Paste the files in your Sitefinity CMS project folder.

3. Open your project in Visual Studio.

4. Include the above files in your solution and build it.

5. Run the project.

6. Create a new *Related data* field.\
   For more information, see [Add a related media custom field](https://www.progress.com/documentation/sitefinity-cms/add-a-related-media-custom-field).\
   Make sure that you are relating to the correct *Data type* and *Source.*

7. Open page `~/RelatedDataMigration.aspx`.

8. Depending on the type of old field you used, from the *Migration type* dropdown menu, select one of the following:

    <table>
    <colgroup><col><col><col></colgroup>
    <tbody>
    <tr>
    <td>

   <strong>Old field</strong>

    </td>
    <td>

   <strong>Migration type</strong>

    </td>
    <td>

   <strong>New field prerequisite</strong>

    </td>
    </tr>
    <tr>
    <td>

   <em>Guid array</em>

    </td>
    <td>

   <em>Multiple Dynamic selector field (Guid array)</em>

    </td>
    <td>

   In the <em>Related data </em>field designer,<br>
   <strong>select</strong> the <em>Multiple items from this data type can be related</em> checkbox.

    </td>
    </tr>
    <tr>
    <td>

   <em>Guid</em>

    </td>
    <td>

   <em>Single Dynamic selector field (Guid)</em>

    </td>
    <td>

   In the <em>Related data </em>field designer,<br>
   <strong>do not select</strong> the <em>Multiple items from this data type can be related</em> checkbox.

    </td>
    </tr>
    <tr>
    <td>

   <em>Media</em>

    </td>
    <td>

   <em>Media field</em>

    </td>
    <td>When creating a new Related media field, make sure you apply the same configuration as the one for the old 
    <em>Media</em> field.<br>
    <strong>NOTE</strong>: The old <em>Media</em> field supports data from multiple providers and the <em>Related media</em> field supports only one provider.
    </td>
    </tr>
    </tbody>
    </table>

9. Fill the form in the *RelatedDataMigration* page with the required data for the migration.\
   For more information about parent and child relations, see [What is related content](https://www.progress.com/documentation/sitefinity-cms/what-is-related-content).
   * *ParentItemType* - the dynamic content type containing the fields
   * *ChildItemType* - the related content type
   * *ParentItemProviderName*
   * *ChildItemProviderName*
   * The old selector or media field name
   * The name of the newly created *Related data* or *Related media* field

10. Click *Migrate data*.\
    The *Migration log* text area provides information about the migration process. For more detailed information about the status of the migration process, check the `Migration.log` file located in the `\App_Data\Sitefinity\Logs` folder. In case of an exception, check the `Error.log` file, located in the same folder.

    > info **NOTE**: Wait for the migration process to be completed before you attempt to access the items being migrated.

11. Check manually whether field values of a few items are accurately migrated.

    > info **NOTE**: You need to refactor any frontend widgets that used the old fields and now need to use the new *Related data* and *Related media* fields.

12. Delete the old selector or media field.

    After you have verified that the new fields contain the accurate migrated data, you can go to the structure of the dynamic module type and delete the old field. This deletes all old records and drops the old field table (in case you used *Guid Array* and media mappings).
