add-sample-data
Use when the user wants to seed Dataverse tables with realistic sample records so a freshly-scaffolded code app shows real-looking data on first launch. Generates contextually appropriate rows from each table's schema and inserts them in dependency order. Mirrors microsoft/power-platform-skills/power-pages/add-sample-data, adapted for mobile apps.
microsoft · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add microsoft/power-platform-skills --skill add-sample-dataAbout this skill
name: add-sample-data description: Use when the user wants to seed Dataverse tables with realistic sample records so a freshly-scaffolded code app shows real-looking data on first launch. Generates contextually appropriate rows from each table's schema and inserts them in dependency order. Mirrors microsoft/power-platform-skills/power-pages/add-sample-data, adapted for mobile apps. user-invocable: true allowed-tools: Read, Edit, Write, Grep, Glob, Bash, AskUserQuestion model: sonnet
📋 Shared instructions: shared-instructions.md — read first.
Add Sample Data
Populate Dataverse tables with realistic sample records so a freshly-scaffolded code app shows real-looking data on first launch. Generates rows from each table's schema and inserts them in dependency order. Use after /add-dataverse (or /setup-datamodel) has created the tables.
Core principles
- Coverage over volume — every table in the manifest gets seeded. The #1 failure mode of a freshly-scaffolded code app is a home / dashboard / list screen that renders an empty state on first launch because its source table has zero rows. An empty downstream table is worse than a 3-row table. Default to minimal-but-complete: small counts everywhere, no table left empty. Volume is a secondary knob — coverage is the contract.
- Insertion order matters. Parent / referenced tables must be inserted before child / referencing tables so lookup IDs are available.
- Contextual data, not Lorem Ipsum. Generate values that match column names + types. A
cr3e9_sitenamecolumn in an inspection app gets "Westside Construction Site", not "Sample Name 1". - Scenario-aware rows. Read
native-app-plan.md, especially### Shared Conventionsand per-screenOperational patternvalues defined in screen-templates.md. Seed rows should exercise the app's actual workflow: statuses, dates, relationships, priority/severity, media metadata, and edge cases that make the planned first viewport light up. - Fail gracefully. On insertion failure, log the error and continue with remaining records — never auto-rollback. The user can re-run after fixing the issue.
- Idempotent re-runs. If a previous run partially completed, the second run reads
memory-bank.md's seeded-data table and skips records already inserted. - Solution-scoped inserts. Always pass
--solution <uniqueName>so records land in our solution, not the default.
Workflow
- Verify project + auth → 2. Discover tables → 3. Select tables + count → 4. Generate + preview → 5. Insert → 6. Summary
Prototype Seed Reuse
--from-seed is used by /prototype-to-real-app after a mock prototype is converted to Dataverse. In this mode, prefer existing prototype seed files before generating new rows:
src/generated/services/*/*.seed.json
src/generated/services/*.seed.json
Map seed objects to Dataverse payloads using .datamodel-manifest.json:
- Keep values only for real manifest columns.
- Translate lookup references into exact
<schemaName>@odata.bindkeys from the manifest. - Keep picklist integers from the manifest; do not invent values from labels.
- Skip local-only prototype fields that have no Dataverse column.
- Preserve dependency-tier insertion order.
If a seed file cannot be mapped safely, fall back to generated contextual sample rows for that table and record DONE_WITH_CONCERNS in the summary. --from-seed is a preference, not permission to insert malformed data.
Step 1 — Verify project & auth
test -f power.config.json && test -f app.config.js
node "${PLUGIN_ROOT}/scripts/resolve-environment.js" "$(node -e \"console.log(require('./power.config.json').environmentId)\")"
Capture the environment URL for subsequent script calls. If resolution fails, instruct az login --tenant <env-tenant> or ask for the environment URL directly, then stop.
Verify Azure CLI auth (the script needs an Azure CLI token):
az account show --query "user.name" -o tsv
If empty, instruct az login and stop.
Step 2 — Discover tables
Telemetry checkpoint: discover_dataverse_tables
Step 2a — Path A: read .datamodel-manifest.json (preferred)
test -f .datamodel-manifest.json
If present, parse the JSON. It already contains logicalName, displayName, status (new / extended / reused), and columns for every table the project uses. This is the preferred path — fast, no API calls.
cat .datamodel-manifest.json | jq '.tables[] | { logicalName, displayName, columnCount: (.columns | length) }'
Skip Step 2b.
Step 2b — Path B: query OData (fallback)
If .datamodel-manifest.json is missing, discover custom tables via the script:
node "${PLUGIN_ROOT}/scripts/dataverse-request.js" <envUrl> GET \
"EntityDefinitions?\$select=LogicalName,DisplayName,EntitySetName&\$filter=IsCustomEntity eq true"
For each table the project uses, fetch its custom columns:
node "${PLUGIN_ROOT}/scripts/dataverse-request.js" <envUrl> GET \
"EntityDefinitions(LogicalName='<table>')/Attributes?\$select=LogicalName,DisplayName,AttributeType,RequiredLevel&\$filter=IsCustomAttribute eq true"
Build the same { logicalName, displayName, columns: [...] } shape the manifest provides.
Step 3 — Select tables + count
All tables from the manifest are evaluated — including reused ones — because a mobile app that surfaces data from a shared table still needs rows to render on first launch. The only exception is standard system tables (e.g. contact, account, systemuser) where seeding is risky in shared production environments.
Pre-seeding row-count check (HARD — runs for every table before generating any rows):
For each table, query its current record count using the entity set name from the manifest (or derive it by appending s to the logical nam