microsoft/power-platform-skills / plugins/power-pages/skills/migrate-datamodel
migrate-datamodel
VerifiedThis skill should be used when the user asks to "migrate to enhanced data model", "migrate from standard to enhanced", "switch to EDM", "migrate SDM to EDM", "upgrade data model", "migrate site data model", or wants to migrate an existing Power Pages site from the Standard Data Model (SDM) to the Enhanced Data Model (EDM) using PAC CLI.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 148.5 KB |
| assets/customization-report.html | other | 8.7 KB |
| scripts/apply-remediation.js | script | 9.7 KB |
| scripts/detect-template.js | script | 11.5 KB |
| scripts/diff-snapshots.js | script | 15.0 KB |
| scripts/emit-telemetry.js | script | 7.3 KB |
| scripts/generate-migration-reports.js | script | 65.8 KB |
| scripts/lib/edm-table-classification.js | script | 3.8 KB |
| scripts/lib/migration-state-schema.js | script | 9.7 KB |
| scripts/lib/render-live-report.js | script | 124.4 KB |
| scripts/migration-runtime.js | script | 15.2 KB |
| scripts/prompts/dme-remediation.template.txt | markdown | 10.9 KB |
| scripts/prompts/plugin-remediation.template.txt | markdown | 4.8 KB |
| scripts/snapshot-site.js | script | 20.5 KB |
| scripts/update-state.js | script | 33.7 KB |
scripts/prompts/dme-remediation.template.txt
View on GitHubYou are an expert in Power Platform solution packaging. The user has a Power
Pages site being migrated from SDM to EDM. A customization scan identified
custom columns on `adx_*` metadata tables that need to be moved into new
custom tables (per Microsoft's migration guidance — `adx_*` tables become
`powerpagecomponent` in EDM, so custom columns can't stay where they are).
The correct fix is to deliver a Dataverse solution package containing:
- One new custom table per affected `adx_*` table
- Each custom column moved to the corresponding new table
- A lookup column on each new table pointing to `powerpagecomponent` (so each
new-table row is associated with its EDM component)
The user will import this solution into their environment and run a separate
data-migration step (covered at the end of this prompt).
## Metadata prerequisite and execution order
Solution schema preparation and packing can happen before metadata migration.
Data copy cannot: before any extension-row writes, confirm the approved metadata
migration has completed for this site and environment, or that the downstream
metadata solution import has completed. The outer migration skill normally
performs that metadata step before generating this handoff; verify it rather
than assuming a standalone invocation has done so.
Run a separate read-only preflight across ALL source rows to verify their target
`powerpagecomponent` rows and expected component types. Build an explicit
source-ID to component-ID mapping (`verifiedComponentIds` in the C# skeleton).
Migration normally preserves the source GUID, but a GUID alone is not evidence
that a matching component exists in the intended environment.
If metadata or any mapping is missing, STOP and return to the migration
conversation. Do not copy data, activate EDM, or start another PAC migration
from this prompt. Resume data copy only after the prerequisite is verified.
## Findings (per-table groupings from the customization report)
{{DME_TABLE_GROUPS_BLOCK}}
## Your task
1. **Ask the user for their publisher prefix** (e.g., `contoso`, `acme`).
This prefix is applied to all new table and column names. If they have an
existing publisher in Dataverse, use it; otherwise help them pick one.
2. **Ask the user for the solution unique name** (e.g.,
`<prefix>_PowerPagesEdmMigration`). This is the solution package name.
3. **Confirm the plan** with the user BEFORE building anything. Show the
list of new tables and the columns/lookups each contains. Wait for
approval.
4. **Initialize a new solution project:**
pac solution init --publisher-name "<Publisher Display Name>" `
--publisher-prefix "<prefix>" `
--outputDirectory "./edm-migration-solution"
5. **For each grouping in the findings, create:**
a. **A new custom table.** Naming: `<prefix>_<original-suffix>` (e.g.,
`adx_webpage` → `contoso_webpage`). Conventions:
- Display name: title-cased original suffix (e.g., "Webpage")
- Primary name column: `<prefix>_name`, string, MaxLength 100
b. **Each custom column from the finding** added to the new table.
Use the SAME column logical name as the original (just on the new
table — `contoso_redirecturl` stays `contoso_redirecturl`, not
renamed).
For column data types, infer from the column logical name (heuristic
only — confirm with user when ambiguous):
- Ends in `name`, contains `text|description|title|code|url|mimetype`:
String, MaxLength 100
- Starts with `is`, `has`, contains `enabled|compressed`: TwoOption
- Contains `count|number` (and not an id): Integer
- Ends in `id` and refers to a Dataverse entity: Lookup (ask user for
the target entity)
- Contains `date|time`: DateTime
- Ambiguous: ASK the user
c. **A lookup column** on the new table pointing to `powerpagecomponent`:
- Logical name: `<prefix>_powerpagecomponentid`
- Display name: "Power Pages Component"
- Required: Yes (each row belongs to exactly one component)
- On-delete behavior: ASK the user (Cascade cleans up extension rows
when the component is deleted; Remove Link sets to null and leaves
orphan rows. Default suggestion: Cascade for tighter coupling.)
6. **Show the user the solution structure** before packing. Show the
directory tree and the entity XML for at least one new table.
7. **Pack the solution:**
pac solution pack --zipfile "./edm-migration-solution.zip" `
--folder "./edm-migration-solution" `
--packagetype Unmanaged
Default to Unmanaged so the user can inspect/modify after import. If the
user plans to deploy to a production environment, ASK whether they want
Managed instead (cleaner uninstall, prevents post-import editing).
8. **Document the import + data migration steps** (print, do NOT run):
a. Import the solution:
pac solution import --path "./edm-migration-solution.zip"
b. **Post-metadata-migration data copy:** after solution import AND the
metadata prerequisite and complete read-only mapping preflight above,
migrate row data from the old `adx_*` tables into the new custom tables.
For each finding:
- Read rows from the source `adx_*` table
- For each row, find the corresponding `powerpagecomponent` row
(joined by primary key — `powerpagecomponent` rows preserve the
original adx_* row ID in EDM)
- Create a row in the new custom table with:
- The lookup column set to the matching `powerpagecomponent`
- The custom column values copied verbatim
Provide TWO sample data-migration approaches:
**Approach 1 — Power Automate flow (low volumes, < 1000 rows):**
Skeleton:
Trigger: Manual / Recurrence
Step 1: List rows from <adx_source_table> via Dataverse connector
Step 2: Resolve the component ID using the verified mapping; stop if absent.
Step 3: For each row → Create a new row in <new_custom_table> with
<prefix>_powerpagecomponentid = verified component ID and
<custom_columns> copied verbatim
**Approach 2 — C# console app (higher volumes, batched):**
Skeleton (supply `verifiedComponentIds` from the complete read-only
preflight before running this write phase):
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
// ... auth setup omitted ...
var sourceQuery = new QueryExpression("adx_<source>") {
ColumnSet = new ColumnSet("<custom_column1>", "<custom_column2>", "<source>id"),
PageInfo = new PagingInfo { Count = 5000, PageNumber = 1 }
};
sourceQuery.AddOrder("<source>id", OrderType.Ascending);
var batch = new ExecuteMultipleRequest {
Requests = new OrganizationRequestCollection(),
Settings = new ExecuteMultipleSettings { ContinueOnError = false, ReturnResponses = false }
};
while (true) {
var sourceRows = service.RetrieveMultiple(sourceQuery);
foreach (var src in sourceRows.Entities) {
if (!verifiedComponentIds.TryGetValue(src.Id, out var componentId)) {
throw new InvalidOperationException("Missing verified component mapping; stop and return to the migration conversation.");
}
var newRow = new Entity("<prefix>_<target>");
newRow["<prefix>_powerpagecomponentid"] = new EntityReference(
"powerpagecomponent", componentId);
newRow["<custom_column1>"] = src.GetAttributeValue<object>("<custom_column1>");
// ... copy remaining custom columns ...
batch.Requests.Add(new CreateRequest { Target = newRow });
if (batch.Requests.Count == 1000) {
var response = (ExecuteMultipleResponse)service.Execute(batch);
if (response.IsFaulted) throw new InvalidOperationException("Data migration batch failed; inspect response.Responses before resuming.");
batch.Requests.Clear();
}
}
if (!sourceRows.MoreRecords) break;
sourceQuery.PageInfo.PageNumber++;
sourceQuery.PageInfo.PagingCookie = sourceRows.PagingCookie;
}
if (batch.Requests.Count > 0) {
var response = (ExecuteMultipleResponse)service.Execute(batch);
if (response.IsFaulted) throw new InvalidOperationException("Data migration batch failed; inspect response.Responses before resuming.");
}
Adapt the placeholders to the user's actual table/column names.
Retrieve every page before declaring completion. Review batch faults and
reconcile already-created rows before retrying; this create-only skeleton
is not safe to rerun blindly.
Paging reference: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/queryexpression/page-results
c. After data migration, the user must:
- Update any Liquid/FetchXML references to the old adx_* custom
columns to instead query the new custom table via its lookup.
(The SDM-to-EDM skill's FetchXML rewriter handles entity-level
changes; custom-column references need this manual update.)
- Reconcile source and target row counts, mappings, custom values and
consumer changes, then return the results to the migration conversation.
Continue only through its existing reference-migration, validation and
activation approval gates; do not rerun metadata migration after data copy.
## References
- SDM to EDM migration: https://learn.microsoft.com/en-us/power-pages/admin/migrate-enhanced-data-model
- pac solution commands: https://learn.microsoft.com/en-us/power-platform/developer/cli/reference/solution
- Solution / ALM concepts: https://learn.microsoft.com/en-us/power-platform/alm/solution-concepts-alm
- Power Pages component types (for understanding the EDM model):
https://learn.microsoft.com/en-us/power-pages/configure/enhanced-data-model
## Constraints
- DO NOT make any direct Dataverse API calls. Generate the solution package
only — the user imports it themselves
- ALL schema decisions (table names, column types, display names, on-delete
behavior) must be reviewed by the user before pack
- Default to Unmanaged solutions for iteration; offer Managed for production
- DO NOT pack until the user has approved the structure
- If the user already has a publisher in their Dataverse environment, prefer
using it rather than creating a new one — ask first
- Generate the solution as a separate directory (`./edm-migration-solution/`)
so it doesn't pollute cwd
- The data-migration step is OUTSIDE the solution import scope — the user
runs it separately. Do NOT include data migration in the solution package
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |