ef-seed

Seed reference and demo data into EF Core databases via HasData migrations or runtime seeders.

Updated May 7, 2026
One-click install
npx skills add https://github.com/Pieter-1337/Euricom-tsz --skill ef-seed-pieter-1337
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ef-seed
Source: https://github.com/Pieter-1337/Euricom-tsz/tree/main/.claude/skills/tsz-ef-seed
Command: npx skills add https://github.com/Pieter-1337/Euricom-tsz --skill ef-seed-pieter-1337

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend modules often need baseline rows—lookup tables, fixed roles, or demo fixtures—before they are usable. This Skill guides you through seeding that data in a .NET EF Core codebase using the right mechanism for the data type, avoiding common pitfalls like non-idempotent seeders or migrations that never run in tests. ## Core Features & Use Cases - HasData() Migrations: Bake static reference data (lookups, enums-as-tables, fixed roles) directly into an EF Core migration via IEntityTypeConfiguration, so it is inserted once per environment. - Runtime Seeders: Create idempotent startup seeders that run through IUnitOfWork after Migrate(), ideal for demo data, dev fixtures, or values HasData cannot express (computed IDs, DateTime.UtcNow). - Use Case: After scaffolding a new backend module, you need a Species lookup table with fixed rows and a demo admin user. Use Mode A for the Species rows baked into a migration, and Mode B for the admin user seeded idempotently at startup in development. ## Quick Start Ask the AI to seed baseline data for your new module, specifying whether the rows are static reference data or demo fixtures so it picks HasData or a runtime seeder.

Frequently Asked Questions about ef-seed

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

FAQPage Schema
How do I seed data in EF Core migrations?

Use HasData() inside your IEntityTypeConfiguration to declare static rows with literal IDs, then run dotnet ef migrations add. The generated migration contains InsertData calls in Up() and matching DeleteData in Down(), applied once per environment.

HasData vs runtime seeder: which should I use?

Use HasData for fixed reference data like lookups and roles with stable IDs baked into migrations. Use a runtime seeder for demo data, dev fixtures, or anything needing computed values like Guid.NewGuid() or DateTime.UtcNow, which HasData cannot express.

Why is my EF Core seeder inserting duplicate rows?

Runtime seeders execute on every application startup, so duplicates appear without an idempotency guard. Check with ExistsAsync before inserting—for example, verify the admin email already exists—and return early if data is present.

Does HasData seed data work with InMemory database in tests?

No. UseInMemoryDatabase does not run migrations, so HasData seed rows are never applied in integration tests. Create the required data inside each test class via a helper like WithUowAsync, or use a runtime seeder instead.

What are the limitations of EF Core HasData?

HasData cannot use computed values such as DateTime.UtcNow or Guid.NewGuid()—IDs must be literals. It also cannot reference rows that are not themselves seeded via HasData, and it becomes unwieldy for hundreds of rows.