bc-dataverse-entity-generator
Skill28 starsChanged 7 months agoMITView on GitHub
Generates AL CDS integration table objects from Dataverse entities using ALTPGen with PowerShell automation scripts. REQUIRES terminal tools. Automatically determines next available table ID, EXECUTES the generation script via terminal, monitors for errors (especially ALTPGen path issues), auto-fixes configuration problems, handles post-generation file organization to src/Table/ with BCS prefix naming convention, DELETES original generated file to prevent duplicates, and UPDATES permission set automatically. FULLY AUTOMATED workflow - agent executes all commands directly. If terminal tools are unavailable, agent must decline to proceed.
In this repository38 other files it gives its agents.
- bc-agent-instructions-debuggerSkill
- bc-al-bug-fixSkill
- bc-al-code-reviewerSkill
- bc-al-project-contextSkill
- bc-api-page-generatorSkill
- bc-api-query-generatorSkill
- bc-approval-workflow-generatorSkill
- bc-attachments-generatorSkill
- skill-batch-processingSkill
- bc-business-events-generatorSkill
- bc-cds-page-generatorSkill
- bc-dataverse-mapping-generatorSkill
- bc-field-propagationSkill
- bc-install-codeunit-generatorSkill
- bc-isolated-storage-generatorSkill
- bc-job-queueSkill
- bc-manifest-handoff-generatorSkill
- bc-matrix-page-generatorSkill
- bc-number-series-generatorSkill
- bc-pricing-refactorSkill
- bc-report-selection-generatorSkill
- bc-reportsSkill
- bc-setup-table-generatorSkill
- bc-setup-wizard-generatorSkill
- bc-table-dimensions-generatorSkill
- bc-telemetry-generatorSkill
- bc-test-codeunit-generatorSkill
- bc-upgrade-codeunit-generatorSkill
- documentation-bc-analysis-generatorSkill
- documentation-bc-architecture-generatorSkill
- documentation-bc-ccn-generatorSkill
- documentation-bc-md-to-docx-converterSkill
- documentation-bc-phase-plan-generatorSkill
- documentation-bc-release-note-generatorSkill
- documentation-bc-technical-spec-generatorSkill
- documentation-bc-user-story-generatorSkill
- onprem-remote-deploySkill
- skill-contribution-assistantSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 6 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Verify within app.json idRanges
- Very specific: line 74
Search for altpgen.exe in VS Code extensions: C:\Users\{User}\.vscode\extensions\ms-dynamics-smb.al-*\bin\win32\altpgen\altpgen.exe
- Very specific: line 76
Update $AltpgenPath in Generate-Entity.ps1
- Very specific: line 80
Add extra Split-Path to calculate correct project root
- Distinctive: line 86
Entity not found: Verify entity name (lowercase) exists in Dataverse
- Distinctive: line 88
Network: Check ServiceUri and connectivity
- Very specific: line 101
Write content to: src/Table/BCSCDS{Entity}.Table.al
- Very specific: line 108
Add tabledata "BCS CDS {Entity}"=RIMD, in tabledata section (alphabetical order)
- Very specific: line 109
Add table "BCS CDS {Entity}"=X, in table section (alphabetical order)
- Very specific: line 161
Verify $ClientId is correct
- Very specific: line 162
Check redirect URI in Azure: msal{ClientId}://auth
- Distinctive: line 163
Ensure user has Dataverse access
- Very specific: line 164
Check API permissions: Dynamics CRM > user_impersonation
- Distinctive: line 167
Verify entity exists in Dataverse
- Very specific: line 168
Use lowercase schema name (e.g., account, not Account)
- Distinctive: line 172
Fix (duplicate object): Check for leftover files in project root.
- Distinctive: line 194
Use proper spacing and indentation
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Business Central Dataverse Entity Generator
Generates AL table objects from Microsoft Dataverse entities using ALTPGen and PowerShell automation. Automates the COMPLETE workflow: table ID allocation, command execution, error detection/fixing, file organization with BCS prefix, original file deletion, and automatic permission set updates.
⚡ FULLY AUTOMATED: Agent takes control of the terminal and executes all commands automatically. User interaction only required for authentication (browser popup for first-time OAuth).
🚨 TERMINAL TOOLS REQUIRED: This skill REQUIRES terminal command execution. If unavailable, agent must decline to proceed.
Prerequisites
- Terminal tools enabled (REQUIRED)
- AL Language extension installed in VS Code (includes ALTPGen)
- Azure AD App Registration with
Dynamics CRM > user_impersonationpermission - Access to target Dataverse environment
- PowerShell scripts configured in
.github/skills/bc-dataverse-entity-generator/scripts/
Automated Workflow
Step 0: Check Terminal Tools Availability
BEFORE starting, verify terminal tools are available:
if terminal tools NOT available:
❌ This process requires terminal command execution to be enabled.
The bc-dataverse-entity-generator skill cannot run manually because it requires:
- Automatic error detection and path fixing
- Real-time monitoring of ALTPGen output
- Automated file organization and cleanup
- Permission set updates
Please enable terminal tools in VS Code agent settings to use this skill.
STOP — do not proceedStep 1: Analyze Request & Determine Next Table ID
- Extract entity name from user request (lowercase: "account", "contact", "quote")
- Scan existing tables in
src/Table/*.al - Extract table IDs using regex:
table\s+(\d+) - Find highest ID and add 1
- Verify within
app.jsonidRanges
Step 2: Execute PowerShell Generation Script
Build and execute command:
cd .github\skills\bc-dataverse-entity-generator\scripts
powershell -ExecutionPolicy Bypass -File ".\Generate-Entity.ps1" -Entity "{entity}" -BaseId {tableId}Agent MUST execute directly via terminal tools
Inform user while executing:
Generating {Entity} CDS table...
Entity: {entity}
Table ID: {tableId} (next available)
Note: Browser may prompt for authentication (first run only)Monitor terminal output for completion or errors.
Step 3: Error Handling & Auto-Fix
ALTPGen Path Error:
- Search for
altpgen.exein VS Code extensions:C:\Users\{User}\.vscode\extensions\ms-dynamics-smb.al-*\bin\win32\altpgen\altpgen.exe - Find latest version automatically
- Update
$AltpgenPathin Generate-Entity.ps1 - Re-execute generation script
Base Path Error:
- Add extra
Split-Pathto calculate correct project root - Update script
- Re-execute
Other Errors:
- Authentication: Inform user to complete browser popup
- Entity not found: Verify entity name (lowercase) exists in Dataverse
- Duplicate ID: Find next available ID, re-execute with new ID
- Network: Check ServiceUri and connectivity
Step 4: Post-Generation File Organization
Automatic steps:
- Locate generated file in project root (e.g.,
Account.al,CDSaccount.Table.al) - Read file content and apply BCS prefix:
- Find table declaration:
table \d+ "CDS {Entity}" - Update to:
table {id} "BCS CDS {Entity}"
- Find table declaration:
- Create properly named file:
- Write content to:
src/Table/BCSCDS{Entity}.Table.al - Example:
Account.al→src/Table/BCSCDSAccount.Table.al
- Write content to:
- Delete original file from project root to prevent duplicate object errors
- Update permission set (
AGENTDEMO.permissionset.al):- Parse existing Permissions section
- Add
tabledata "BCS CDS {Entity}"=RIMD,in tabledata section (alphabetical order) - Add
table "BCS CDS {Entity}"=X,in table section (alphabetical order) - Maintain proper comma placement (last entry ends with
;)
- Confirm completion:
✅ {Entity} CDS table generated successfully!
Created: src/Table/BCSCDS{Entity}.Table.al
Table ID: {tableId}
Table Name: "BCS CDS {Entity}"
✅ Cleaned up: Deleted {originalFile} from project root
✅ Updated: AGENTDEMO.permissionset.al with table permissions
Next steps:
- Review the generated table structure
- Build project: Ctrl+Shift+P → AL: Build
- Test integration with Dataverse environmentConfiguration: Sensitive Variables
Scripts contain environment-specific and sensitive values in Generate-Entity.ps1:
| Variable | Type | Purpose | How to Find |
$ServiceUri | ENVIRONMENT | Dataverse environment URL | Power Platform Admin Center > Environments > Environment URL |
$ClientId | SECRET | Azure AD App Registration client ID | Azure Portal > App Registrations > Application (client) ID |
$RedirectUri | SECRET | OAuth redirect URI (auto-generated from ClientId) | Format: msal{ClientId}://auth |
$AltpgenPath | ENVIRONMENT | Path to ALTPGen.exe (version-specific) | VS Code extensions folder (agent can auto-detect) |
See script comments for detailed configuration instructions.
Common Entity Names
| Entity | Description |
account | Customer/company |
contact | Person |
lead | Potential customer |
opportunity | Sales opportunity |
quote | Price quote |
salesorder | Sales order |
invoice | Customer invoice |
product | Product/service |
Troubleshooting
Error: "ALTPGen tool not found"
Auto-fix: Agent searches for ALTPGen.exe, updates path, re-executes
Error: "Authentication failed"
- Verify
$ClientIdis correct - Check redirect URI in Azure:
msal{ClientId}://auth - Ensure user has Dataverse access
- Check API permissions:
Dynamics CRM > user_impersonation
Error: "Entity not found"
- Verify entity exists in Dataverse
- Use lowercase schema name (e.g.,
account, notAccount)
Error: "Duplicate table ID" or "Duplicate object"
Auto-fix (ID): Agent rescans for next available ID, re-executes Fix (duplicate object): Check for leftover files in project root; agent should delete automatically
Permission Set Update Details
File structure: namespace AGENTDEMO; permissionset 70000 AGENTDEMO { Assignable = true; Permissions = ... }
Sections order: tabledata → table → codeunit → page
Format:
Permissions =
tabledata "BCS CDS Account"=RIMD,
tabledata "BCS CDS Contact"=RIMD,
table "BCS CDS Account"=X,
table "BCS CDS Contact"=X,
codeunit "BCS ..."=X,
page "BCS ..."=X;Rules:
- Maintain alphabetical order within each section
- Each entry ends with
,except the last entry (ends with;) - Use proper spacing and indentation
Quick Reference
Navigate to Scripts
cd .github\skills\bc-dataverse-entity-generator\scriptsGenerate Single Entity (Manual)
powershell -ExecutionPolicy Bypass -File ".\Generate-Entity.ps1" -Entity "account" -BaseId 70004Find Next Table ID (Manual)
Get-ChildItem ..\..\..\..\src\Table\*.al |
ForEach-Object { if ((Get-Content $_.FullName -Raw) -match 'table\s+(\d+)') { [int]$matches[1] } } |
Sort-Object | Select-Object -Last 1Script Locations
.github/skills/bc-dataverse-entity-generator/
├── SKILL.md # This file
├── scripts/
│ ├── Generate-Entity.ps1 # Single entity generator (with sensitive variable documentation)
│ └── Generate-Entity-List.ps1 # Batch entity generatorExternal Resources
Agent Workflow Summary
- ✅ Check terminal tools available (STOP if not)
- ✅ Extract entity name, determine next table ID
- ✅ Execute PowerShell script via terminal
- ✅ Monitor output, auto-fix errors (ALTPGen path, base path)
- ✅ Locate generated file in project root
- ✅ Apply BCS prefix, create file in src/Table/
- ✅ Delete original file from project root
- ✅ Update AGENTDEMO.permissionset.al automatically
- ✅ Confirm completion with file paths and next steps
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

