Skip to content
Back to skills

Coreex Refdata

ASecurity

Add or modify a reference data type in a CoreEx domain. USE FOR: new ref-data entity (new table + seed rows + CodeGen), adding extra properties to an existing type, adding seed rows for an existing type, wiring an existing ref-data type into a contract. DO NOT USE FOR: non-reference-data entity tables (use coreex-db-migration), hand-authoring generated .g.cs contracts (always use CodeGen).

  • 29 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added August 31, 2026
databasesgosqlrailsgitapidatabase

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add Avanade/CoreEx --skill coreex-refdata --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coreex Refdata?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coreex Refdata
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/avanade-coreex-refdata/badge)](https://www.skillsdirectory.com/skills/avanade-coreex-refdata)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: coreex-refdata
description: "Add or modify a reference data type in a CoreEx domain. USE FOR: new ref-data entity (new table + seed rows + CodeGen), adding extra properties to an existing type, adding seed rows for an existing type, wiring an existing ref-data type into a contract. DO NOT USE FOR: non-reference-data entity tables (use coreex-db-migration), hand-authoring generated .g.cs contracts (always use CodeGen)."
argument-hint: "Optional: entity name(s), domain, extra properties beyond standard Code/Text, seed rows"
tags: ["refdata", "codegen", "database", "contracts", "reference-data", "coreex"]
---

<!--
  AI workflow asset — dual-audience notice:
  - In the Avanade/CoreEx repository: this file is the authored source. Edit it here.
  - In a consumer repository: this file was generated by `dotnet new coreex-ai` (or refreshed via
    `dotnet new coreex-ai --force` / the `/coreex-docs-sync` skill). Do not hand-edit it directly —
    propose the change upstream in Avanade/CoreEx instead, then refresh once it is released.
-->

# CoreEx: Reference Data

Guides you through the complete end-to-end workflow for adding or modifying a reference data (Code/Text lookup) type in a CoreEx domain — covering both the persistence side (`*.Database`, relational DbEx or Cosmos provisioning) and the CodeGen side (`*.CodeGen`).

## When to Use

- Adding a new reference data type — new table, seed rows, and generated contracts/services/repos
- Adding extra stored properties to an existing type (beyond the standard `IReferenceData` fields)
- Adding or amending seed rows for an existing type
- Modifying an existing type's pluralization or identifier type
- Making a type mutable (`mutability` — generated create/patch/activate/deactivate/delete endpoints and service)
- Wiring an existing ref-data type into a new or existing contract via `[ReferenceData<T>]`

## When Not to Use

- Creating a non-reference-data entity table — use `coreex-db-migration`
- Provisioning the transactional outbox — use `dotnet run -- script outbox <schema> <name>` directly; see `coreex-tooling.instructions.md`
- Hand-authoring reference data contract `.g.cs` files — always go through CodeGen; only hand-author optional `partial` extension classes on top of the generated output
- Changes to the API controller, service, or repository generated by CodeGen — re-run CodeGen; never edit `.g.cs` files

## Quick Reference

- Consume codes through [generated implicit conversion](/.github/instructions/coreex-contracts.instructions.md#reference-data-code-conversion) to concrete reference-data types, not custom `RefData<T>` helpers. Contracts use annotated partial `XxxCode` properties, not plain code auto-properties; conversion does not validate requiredness, validity or activity.
- For a patch DTO that must distinguish an omitted code from an explicit clear, use an annotated `partial Optional<string?> XxxCode` property; the generator supplies a presence-sharing optional navigation accessor. Keep this wrapper out of persisted/reference-data entities.

> **Resolve project-wide choices from state before asking.** Read the solution-root `AGENTS.md`
> **Feature Configuration** for `refdata-enabled` (gates this whole skill) and `data-provider`
> (`SqlServer` / `Postgres` / `Cosmos` — drives whether the database step is DbEx or Cosmos provisioning, plus casing/seed shape). Only prompt for what is unrecorded;
> include resolved values in the implementation plan.

**Two separate `dotnet run` steps in two different projects — never conflate them.**

| Task | Project | Command / File |
|---|---|---|
| Bring persistence baseline up to date | `*.Database` | Relational: `dotnet run -- database`; Cosmos: inspect `Program.ConfigureProvisionArgs(...)` + run `dotnet run -- All` |
| Inspect table/container state | `*.Database` | Relational: `dotnet run -- inspect <schema> <table>`; Cosmos: review declared container ids + seed files |
| New ref-data persistence shape | `*.Database` | Relational: `dotnet run -- script refdata <schema> <table>`; Cosmos: keep `ReferenceDataContainer("ref-data")` and update its seed data / accessors |
| Add/amend seed rows | `*.Database` | Edit `Data/ref-data.seed.yaml` (relational or Cosmos `ref-data` container) |
| Register table in EF model | `*.Database` | Relational only: edit `dbex.yaml` → `tables:` |
| Apply persistence + regenerate EF models/accessors | `*.Database` | Relational: `dotnet run -- All`; Cosmos: `dotnet run -- All` (provisions/imports; no EF generation) |
| Add/update entity definition | `*.CodeGen` | Edit `ref-data.yaml` → `entities:` |
| Generate all ref-data artefacts | `*.CodeGen` | `dotnet run` |

> **Mutability is opt-in and secured by default, but has no referential-integrity protection.** Mutable endpoints require authorization by default (`[Authorize]`); use `mutableAttribute` to apply a specific policy/role or `[AllowAnonymous]` only when intentionally public. Delete/deactivate never check whether the code is still referenced elsewhere. Warn the user and point them at the `PreCheckAsync` hook — see "Mutable types" in `references/workflow.md`.

## The Two YAML Files — Never Confuse Them

| File | What it contains |
|---|---|
| `*.CodeGen/ref-data.yaml` | Entity/contract **definitions** (`entities:` with `name`, `idType`, `properties`) |
| `*.Database/Data/ref-data.seed.yaml` | Seed **rows** (`Schema:` → `- $^Table:` → rows) |

Putting entity definitions in the seed file, or seed rows in the entity file, is the single most common mistake.

## Polyglot Note

| Provider | Persistence shape | Seed shape |
|---|---|---|
| PostgreSQL | `snake_case` tables + `.pgsql` scripts | `Data/ref-data.seed.yaml` under the schema key |
| SQL Server | `PascalCase` tables + `.sql` scripts | `Data/ref-data.seed.yaml` under the schema key |
| Cosmos | `ReferenceDataContainer("ref-data")` in `ConfigureProvisionArgs(...)` | `Data/ref-data.seed.yaml` keyed by `ref-data`, with grouped `$^TypeName` entries |

Check the project's `*.Database/Program.cs` to confirm the provider in use.

For the full decision tree, YAML examples, seeding rules, and guardrails see [`references/workflow.md`](references/workflow.md).

## Key References

- [`/.github/instructions/coreex-tooling.instructions.md`](/.github/instructions/coreex-tooling.instructions.md) — `ref-data.yaml` structure, `dbex.yaml`, seed format, `Script`/`All`/`Data` commands
- [`/.github/instructions/coreex-contracts.instructions.md`](/.github/instructions/coreex-contracts.instructions.md) — `[ReferenceData<T>]`, `partial` properties, global usings
- Related skills: [`coreex-contract`](../coreex-contract/SKILL.md) (wires `[ReferenceData<T>]` into contracts), [`coreex-db-migration`](../coreex-db-migration/SKILL.md) (ref-data table schema)
- Illustrative examples (CoreEx sample — not present in your project):
  - [PostgreSQL CodeGen definition](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Products.CodeGen/ref-data.yaml) and its [seed file](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Products.Database/Data/ref-data.seed.yaml)
  - [SQL Server CodeGen definition](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Shopping.CodeGen/ref-data.yaml) and its [seed file](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Shopping.Database/Data/ref-data.seed.yaml)
  - [Cosmos CodeGen definition](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Customers.CodeGen/ref-data.yaml) and its [seed file](https://github.com/Avanade/CoreEx/blob/main/samples/src/Contoso.Customers.Database/Data/ref-data.seed.yaml)

Files in this skill

  • SKILL.md5.2 KB
  • references/workflow.md12.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in databases →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.