| name | dataverse-add-data-source |
| description | Add a Dataverse table to a Power Apps Code App as a data source (and refresh its generated schema) via the npm power-apps CLI. Use when asked to "add a Dataverse table to the Code App", "add a data source", "regenerate/refresh the typed model/service", or wire a table into the app's generated SDK. |
| metadata | {"author":"chuckytesla","version":"1.0.0","argument-hint":"-t <logical-name> [more logical names…]"} |
Add a Dataverse table as a Code App data source
Registers a Dataverse table with the Power Apps Code App
and runs the SDK code generation so your app gets a typed XxxModel + XxxService to code
against. Re-running for a table that's already wired refreshes the schema — it regenerates the
model/service to match the table's current columns. The skill is a generic engine: the table
logical name is an input you provide (or the agent asks for); nothing project-specific is baked in.
The command
npx power-apps add-data-source -a dataverse -t <logical-name> --environment <environment-url>
-a dataverse — the data-source kind (Dataverse).
-t <logical-name> — the table's logical name (singular, lowercase, e.g. eppc_session — not
the entity-set/plural eppc_sessions, and not the display name).
--environment <environment-url> (alias -env) — the environment / org URL, e.g.
https://orgXXXXXXXX.crm.dynamics.com. Pass this explicitly. Without it the CLI prompts
interactively for the org URL, and that prompt is exactly what stalls an agent run: the command
blocks on a background/hidden terminal waiting for input the agent does not reliably type. Supplying
the flag makes the command non-interactive, so neither the agent nor the user has to enter anything.
Fill it from .env (DATAVERSE_URL) — see Inputs.
Run it once per table. To wire (or refresh) several, run the command once for each logical name.
Inputs (provide, derive, or ask)
| Input | How it's used | If unknown |
|---|
| Table logical name | -t <logical-name> | Derive from the schema file (tables[].schemaName lowercased) or from power.config.json → databaseReferences.default.cds.dataSources[].logicalName; otherwise ask the user. Never guess the plural/display form. |
| Environment / org URL | --environment <url> (alias -env) | Read DATAVERSE_URL from .env — the same value the dataverse-scaffold-tables skill uses (e.g. https://orgXXXXXXXX.crm.dynamics.com) — and substitute it into the command. .env is a file, not exported shell variables, so the CLI does not read it for you and $DATAVERSE_URL is not set in the shell: open .env, take the value, and write it into the command literally. If .env has no DATAVERSE_URL, ask the user; do not guess. |
Never hardcode the table name or the URL into the skill — they belong to the project, not the skill.
Prerequisites
- Run from the Code App root (the folder with
power.config.json and package.json).
- Signed in:
npx power-apps login (the account that owns the environment). If a call reports an
interaction/consent error, re-run the login.
- The table already exists in the environment. To create it first, use the
dataverse-scaffold-tables skill, then come back here to wire it up.
⚠️ This is the highest-risk command
add-data-source generates files (src/generated/models/XxxModel.ts,
src/generated/services/XxxService.ts) and edits power.config.json (databaseReferences … dataSources). Per AGENTS.md, verify the exact verb and flags on a dry run
before relying on them — the CLI is still preview and the surface can shift.
npx power-apps add-data-source --help
Check that -a/--app-type (or equivalent), -t/--table, and --environment (alias -env) match what
--help prints — the npm power-apps CLI is preview, so confirm the exact flag name before relying on
it — then run the real command. If this version names the environment flag differently, use that
name with the same .env value.
Steps
- Confirm you're in the app root and signed in (prerequisites above).
- Dry-check the flags:
npx power-apps add-data-source --help and reconcile with the command above,
confirming --environment / -env exists.
- Resolve the inputs: the logical name (from the schema file /
power.config.json, or ask) and the
environment URL (DATAVERSE_URL from .env, or ask).
- Run
npx power-apps add-data-source -a dataverse -t <logical-name> --environment <environment-url>
— once per table, with the URL filled in from .env so there is no interactive prompt to answer.
- Verify (see below).
After running
- A new/updated
dataSources entry appears in power.config.json under
databaseReferences.default.cds.dataSources (with entitySetName, logicalName).
src/generated/models/<Name>Model.ts and src/generated/services/<Name>Service.ts exist and match
the table's columns. Run tsc (near-instant) to confirm the app still typechecks against them.
- Code against the generated
Model/Service only — do not hand-roll a Dataverse client, and prefer
deleting + regenerating over hand-editing the generated files (they're overwritten on the next run).
Notes
- Refreshing the schema = re-running the same command for an already-wired table; it regenerates the
model/service so they reflect added/changed columns. Safe to repeat.
- Logical name vs. entity-set name:
add-data-source wants the logical (singular) name; the plural
entitySetName is what the CLI writes into power.config.json for you.
- Related skills:
scaffold-code-app (bootstrap the app), dataverse-scaffold-tables (create the table),
dataverse-create-records (seed rows).