Part 3 of a five-part series on SitecoreAI migration and my new migration tool.
The first two posts covered the migration problems and the design of V3 of my migration tool. This post follows a small migration through the actual workflow: acquire source content, write a plugin, generate instructions and preview their application in Sitecore.
The example copies an English content branch while preserving item IDs. It assumes compatible target templates already exist. It deliberately leaves page composition to a separate mapping, so it is a useful first exercise rather than a complete legacy-to-headless conversion.
Get the tool and project prerequisites in place
You need a published V3 command host (The .exe and the source code is available for free on GitHub), its SDK assembly, a .NET SDK suitable for your plugin project, and the target-side Migrate-Data.ps1 script.
The examples use the .NET 8 host. V3 also has a .NET Framework 4.8.1 host; the plugin and host need compatible target frameworks.
Create the plugin project using the project file in the V3 quickstart. It references Nevnet.Sitecore.Migration.Sdk.dll and includes the compatibility dependency needed when consuming that raw DLL. The project does not need Sitecore assemblies.
A simple working directory can contain:
| File or directory | Purpose |
|---|---|
| Migration.Project.csproj | Builds the project-specific plugin. |
| CopyContent.cs | Contains the migration entry. |
| tools/ | Holds the SDK assembly referenced by the project. |
| source/ | Contains the exported source items. |
| output/ | Receives generated instruction files. |
Keep source exports and generated output in different directories.
Choose how to acquire the source
The YAML provider reads Sitecore serialization files. If the source has a suitable CLI serialization configuration, pull the configured modules:
dotnet sitecore ser pull
That command uses the project's authentication, environment and module settings. It does not automatically mean “export everything.” The configured scope needs to include the items and dependencies your plugin will query.
The YAML provider recursively scans physical .yml and .yaml files and ignores Sitecore's .scindex files.
Alternatively, run the included source exporter in the source Sitecore PowerShell ISE. Select the database and subtree through the ISE context, then run the complete script. Its default ZIP download contains items.ndjson.
The exporter offers these source-version choices:
| Setting | What it exports |
|---|---|
| Latest (Default) | The latest authored version per selected language, regardless of publication eligibility. |
| All | Every authored version in the selected languages. |
| Publishable | The version selected by Sitecore's publishing rules at the specified time, when eligible. |
An empty language list means all source database languages. Publication eligibility is not the same as reproducing the exact contents of a live publishing target. If that is what you need, then simply change the database context in Sitecore PowerShell ISE to 'web' instead of 'master'.
The exporter reads directly stored field values. It does not materialize standard values, inherited defaults or language fallback into every record. This is a deliberate design choice as it is expected that your target Sitecore instance will already be configured with templates that have intentional values provided for standard values and fallback. Decide whether your transformation needs those behaviors before treating an absent value as missing content.
Understand the two NDJSON formats
NDJSON means one complete JSON object per physical line. It is convenient for reading records without wrapping the whole file in a JSON array. It is a highly efficient file format for working with large amounts of structured data.
The workflow uses it for two different purposes:
| File | What a line represents | Consumer |
|---|---|---|
| Source items.ndjson | An item, its identity and its field maps. | The NDJSON source provider. |
| Generated CopyContent.ndjson | An operation such as create or update fields. | The target PowerShell script. |
A source record retains shared, unversioned and versioned fields separately. Language and actual numeric source version appear as map keys.
A generated instruction looks like this:
{"Action":"UpdateFields","ItemId":"{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}","Fields":{"Versioned":{"en":{"First":{"Title":"Example page"}}}}}
Here, First is a target selector understood by the consumer. It does not claim the source content originally came from version 1.
Do not pass the raw source export directly to Migrate-Data.ps1. It has item records, not migration instructions.
Write a small, explicit plugin
This example queries the Home branch, selects the latest English fields and normalizes them to the first target version.
It omits legacy presentation, workflow and security fields so those can remain under the target implementation's control:
using System;
using System.Threading;
using System.Threading.Tasks;
using Nevnet.Sitecore.Migration.Sdk;
using Nevnet.Sitecore.Migration.Sdk.Instructions;
using Nevnet.Sitecore.Migration.Sdk.Plugins;
public static class CopyContent
{
private const string SourceRoot = "/sitecore/content/SiteCollection/Site/Home";
[MigrationEntry("CopyContent")]
public static async Task RunAsync(IMigrationJob job, CancellationToken cancellationToken)
{
var source = job.Repositories.Get("source");
var query = ItemQuery.Create().Path(SourceRoot).Build();
foreach (var current in source.ExecuteQuery(query))
{
var snapshot = await current.GetFieldsAsync(cancellationToken: cancellationToken);
var fields = snapshot.Project()
.ForLanguages("en")
.Latest()
.NormalizeToFirst()
.Build();
fields.RemoveShared("__Renderings")
.RemoveShared("Page Design")
.RemoveShared("__Workflow")
.RemoveShared("__Default workflow")
.RemoveShared("__Security")
.RemoveFirstVersion("en", "__Final Renderings")
.RemoveFirstVersion("en", "__Workflow state")
.RemoveFirstVersion("en", "__Lock");
var parent = string.Equals(current.Item.Path, SourceRoot, StringComparison.OrdinalIgnoreCase) ? "/sitecore/content/SiteCollection/Site" : null;
job.Instructions.CreateItemWithFields(current.Item, fields, parentId: parent);
}
}
}
The query includes the root and descendants. It uses indexed metadata; the field read happens when the loop reaches an item. Projection creates a detached mutable container of type FieldContainer, leaving the cached source snapshot unchanged. FieldContainer has a rich API that facilitates many different field manipulations, including the obvious requirement to add, remove, rename fields, set field values or remove them completely.
For the Home item, the example supplies the target site path as its parent. Descendants retain their source parent IDs. The target site, languages and compatible templates must already exist, and the chosen item IDs must not conflict with unrelated target content. This is a good example of how item or entire sections of the content tree can be moved or re-parented in the target.
The Remove... calls omit fields from the update. They do not clear target presentation or workflow. Other fields are copied under their existing names, so changed template contracts require additional mappings. If field name in the target have changed, this is where field names could be mapped from old to new.
This example includes descendants such as local data items. Refine the query when different branches need different transformations.
Build, inspect and generate
Build the plugin, then ask V3 to discover its entries:
dotnet build .\Migration.Project.csproj -c Debug
$tool = "C:\tools\migration\net8.0\Migrate.exe"
$plugin = ".\bin\Debug\net8.0\Migration.Project.dll"
& $tool entries -a $plugin
The entry name CopyContent comes from the attribute and becomes the default output filename.
Validate the configuration first:
& $tool generate `
-s ".\source" `
--source-provider yaml `
-a $plugin `
-e CopyContent `
-o ".\output" `
--check
For an NDJSON export, use --source-provider ndjson and point -s to the file or export folder.
--check opens repositories and validates plugin discovery and configuration. It does not invoke RunAsync, so it cannot prove that your transformations are correct.
Run the same command without --check to generate output/CopyContent.ndjson. Inspect its operations and field maps. In particular, check root placement, language/version selectors and any source-specific fields that should not reach the target. Remember, by running the Migrate.exe tool, you are only generating the .ndjson instruction output file - Nothing gets imported into your target system yet!
Run the importer in the target Sitecore context
Migrate-Data.ps1 uses Sitecore APIs. Run it in a PowerShell process with the target Sitecore application loaded, such as the target's PowerShell ISE. It will not work merely because PowerShell is installed on your laptop.
SitecoreAI exposes its PowerShell ISE through the Desktop development tools; access can depend on the environment's elevation configuration. Store custom scripts outside Sitecore's system-managed Migration script-library node. Sitecore PowerShell guidance, serialization and script-library guidance
The importer accepts a local path visible to the target process, or an HTTP/HTTPS URL that returns the raw instruction file:
.\Migrate-Data.ps1 `
-Url "https://files.example.com/migrations/CopyContent.ndjson" `
-Database master `
-DryRun `
-VerboseOutput
Review the proposed actions and warnings. A dry run does not create items, so later instructions can report missing items that earlier create instructions would have produced. It is a preview, not a simulated target database.
Apply the reviewed file to a disposable lower environment by running the command without -DryRun. Read the warnings and failure summary, then inspect the resulting items and their fields. Publishing and frontend validation remain separate steps.
Keep the first run intentionally small
The useful milestone is one branch whose source, transformation, output and target result you understand.
From there, add explicit template mappings, shared dependencies and presentation reconstruction. Keep each addition small enough that a reviewer can explain why the generated instructions changed.
The next post uses that approach to rebuild a legacy page whose content was scattered across several source items. The complete exporter, importer and project setup belong in the repository; the blog examples are intended to make the mechanics easier to follow.

