| 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>
-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).
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. |
Never hardcode the table name into the skill — it belongs 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) and -t/--table match what --help prints, then run the
real command.
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.
- Resolve the logical name from the schema file /
power.config.json (or ask the user).
- Run
npx power-apps add-data-source -a dataverse -t <logical-name> — once per table.
- 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).