microsoft/power-platform-skills / plugins/code-apps/skills/add-dataverse
add-dataverse
VerifiedAdds Dataverse tables to a Power Apps code app with generated TypeScript models and services. Can also create new Dataverse tables. Use when connecting to Dataverse, adding tables, creating schema, or querying Dataverse data.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.6 KB |
| references/api-authentication-reference.md | markdown | 5.2 KB |
| references/data-architecture-reference.md | markdown | 3.7 KB |
| references/dataverse-reference.md | markdown | 12.8 KB |
| references/table-management-reference.md | markdown | 15.5 KB |
references/data-architecture-reference.md
View on GitHub# Data Architecture Reference
## Relationship Types
- **1:N (One-to-Many)**: Parent table referenced by child via Lookup. Parent must exist first.
- **N:N (Many-to-Many)**: Junction table created automatically. Both tables must exist first.
- **Self-Referential**: Table references itself. Table must exist before adding self-lookup.
## Dependency Tiers
Create tables in order by their dependencies:
- **Tier 0**: Reference/lookup tables (no dependencies) - Category, Status, Department
- **Tier 1**: Primary entities (reference Tier 0) - Product->Category, Employee->Department
- **Tier 2**: Dependent/transaction tables (reference Tier 1) - Order->Customer, OrderLine->Order
- **Tier 3**: Deeply nested tables (rare)
## Common Relationship Patterns
| App Feature | Tables | Relationships |
|-------------|--------|---------------|
| **Inventory** | Category, Asset, ServiceRecord | Category(0) -> Asset(1) -> ServiceRecord(2) |
| **Helpdesk** | Category, Priority, Ticket, Comment | Category(0), Priority(0) -> Ticket(1) -> Comment(2) |
| **Project Tracker** | Department, Project, Task | Department(0) -> Project(1) -> Task(2) |
| **CRM** | Account, Contact, Opportunity | Account(0) -> Contact(1) -> Opportunity(2) |
| **Event Mgmt** | EventType, Event, Registration | EventType(0) -> Event(1) -> Registration(2) |
## Adding Lookups
```powershell
function Add-DataverseLookup {
param(
[string]$SourceTable, # Table getting the lookup column
[string]$TargetTable, # Table being referenced
[string]$SchemaName, # Lookup column schema name
[string]$DisplayName # Lookup column display name
)
$lookup = @{
"@odata.type" = "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata"
"SchemaName" = "${publisherPrefix}_${TargetTable}_${SourceTable}"
"ReferencedEntity" = $TargetTable
"ReferencingEntity" = $SourceTable
"Lookup" = @{
"@odata.type" = "Microsoft.Dynamics.CRM.LookupAttributeMetadata"
"SchemaName" = $SchemaName
"DisplayName" = @{
"@odata.type" = "Microsoft.Dynamics.CRM.Label"
"LocalizedLabels" = @(@{
"@odata.type" = "Microsoft.Dynamics.CRM.LocalizedLabel"
"Label" = $DisplayName
"LanguageCode" = 1033
})
}
}
"CascadeConfiguration" = @{
"Assign" = "NoCascade"
"Delete" = "RemoveLink"
"Merge" = "NoCascade"
"Reparent" = "NoCascade"
"Share" = "NoCascade"
"Unshare" = "NoCascade"
}
}
$body = $lookup | ConvertTo-Json -Depth 10
Invoke-RestMethod -Uri "$baseUrl/RelationshipDefinitions" -Method Post -Headers $headers -Body $body
}
function Add-DataverseLookupIfNotExists {
param(
[string]$SourceTable,
[string]$TargetTable,
[string]$SchemaName,
[string]$DisplayName
)
if (Test-ColumnExists -TableLogicalName $SourceTable -ColumnLogicalName $SchemaName.ToLower()) {
Write-Host " [SKIP] Lookup '$SchemaName' already exists on '$SourceTable'" -ForegroundColor Yellow
return
}
Write-Host " [CREATE] Adding lookup '$SchemaName' on '$SourceTable' -> '$TargetTable'..." -ForegroundColor Cyan
Add-DataverseLookup -SourceTable $SourceTable -TargetTable $TargetTable -SchemaName $SchemaName -DisplayName $DisplayName
Write-Host " [OK] Lookup created" -ForegroundColor Green
}
```
## Validation Rules
Before table creation, validate:
1. No circular dependencies
2. All referenced tables exist
3. Lookup targets have primary keys
4. Self-references: create table first, then add self-lookup
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |