coreex-db-migration

Scaffolds and applies DbEx database migrations for CoreEx domains on SQL Server or PostgreSQL.

28|8|Updated Feb 21, 2022
One-click install
npx skills add https://github.com/Avanade/CoreEx --skill coreex-db-migration-avanade
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coreex-db-migration
Source: https://github.com/Avanade/CoreEx/tree/main/.github/skills/coreex-db-migration
Command: npx skills add https://github.com/Avanade/CoreEx --skill coreex-db-migration-avanade

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Making database schema changes in a CoreEx project involves choosing the right DbEx migration script type, writing provider-correct SQL, registering tables in dbex.yaml, and regenerating EF persistence models — a multi-step process where mistakes (editing applied scripts, hand-editing generated files, wrong column types) break the migration pipeline. ## Core Features & Use Cases - Guided script selection: Branches across five paths — new transactional table, new reference-data table, alter existing table, non-entity schema change, or no-op — gated by a mandatory dotnet run -- inspect baseline check. - Polyglot SQL templates: Provides canonical column templates and .NET-to-SQL type mappings for both SQL Server (PascalCase, .sql) and PostgreSQL (snake_case, .pgsql), including JSON columns, audit columns, and logical delete. - End-to-end regeneration: Applies migrations via dotnet run -- All and validates the regenerated *.g.cs persistence models and DbContext, with strict guardrails against editing generated files or applied scripts. - Use Case: A developer adding a new Product table with a JSON Tags column runs the skill to scaffold the create script, configure the columns: entry in dbex.yaml, apply the migration, and confirm the typed property and JSON converter appear in the generated code. ## Quick Start Ask the AI to add a new database table or alter an existing one for your CoreEx domain, specifying the entity name, schema, and whether you use SQL Server or PostgreSQL.

Frequently Asked Questions about coreex-db-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new database table in a CoreEx project?▼

Run `dotnet run -- script create <schema> <table>` from the *.Database project directory, fill in the domain columns using the provider's template, register the table in dbex.yaml, then run `dotnet run -- All` to apply the migration and regenerate the persistence models.

How do I alter an existing table with DbEx migrations?▼

Run `dotnet run -- script alter <schema> <table>` and author ALTER TABLE statements for the delta only. The original create script is immutable and dbex.yaml needs no change since the table entry already exists.

Does CoreEx DbEx support both SQL Server and PostgreSQL?▼

Yes, DbEx supports both providers with different conventions. SQL Server uses PascalCase names and .sql files, while PostgreSQL uses snake_case names and .pgsql files. Check the project's Program.cs or appsettings.json to confirm the provider.

How do I store a JSON column in a CoreEx database table?▼

Name the column with a Json suffix (SQL Server) or _json suffix (PostgreSQL), then add a columns entry in dbex.yaml with name, property, and type fields. DbEx auto-wires TypeToJsonStringEfConverter in the generated DbContext when the type is non-string.

When should I not use the CoreEx database migration workflow?▼

Do not use it for outbox provisioning (run `dotnet run -- script outbox` directly), reference-data seed-only changes (edit ref-data.seed.yaml and run `dotnet run -- Data`), or contract and service generation, which belongs to CodeGen rather than the Database project.

Why should I never edit a DbEx migration script after it is applied?▼

DbEx tracks applied scripts in its journal and runs each exactly once, so editing an applied script has no effect and creates state mismatches. Author a new migration script for any subsequent schema delta instead.