Files
duempelkas/.github/prompts/03-dbcontext-mappings.prompt.md
troogs e589cc170a Add GitHub Copilot prompt files
- Step-by-step prompts for solution skeleton, domain model,
  DbContext mappings, application services, UI shell/pages,
  PDF export, and tests/validation
2026-03-31 17:12:35 +02:00

1.4 KiB

description, agent
description agent
Implement FinanceDbContext with fluent entity configurations, indexes, relationships, and SQLite connection setup agent

Step 3: DbContext & Mappings

Create src/Duempelkas.Infrastructure/Persistence/FinanceDbContext.cs.

DbSets

  • DbSet<Account> Accounts
  • DbSet<AccountYear> AccountYears
  • DbSet<Entry> Entries
  • DbSet<TransferLink> TransferLinks

Connection

  • Accept SQLite connection string via constructor options.
  • Default path: Data Source=duempelkas.db in the app's base directory.

Entity Configurations (use OnModelCreating with IEntityTypeConfiguration<T> or inline)

Account

  • Name required, max length 200.
  • Cascade delete → AccountYears.

AccountYear

  • Unique index on (AccountId, Year).
  • OpeningBalance column type decimal(18,2).
  • Cascade delete → Entries.

Entry

  • Index on (AccountYearId, Date).
  • Amount column type decimal(18,2).
  • Type stored as int.
  • Optional FK to TransferLink (TransferLinkId), restrict delete.
  • Unique index on SourceEntryId.
  • Unique index on TargetEntryId.
  • Relationships to SourceEntry and TargetEntry with DeleteBehavior.Restrict.

Notes

  • Use separate IEntityTypeConfiguration<T> classes in Persistence/Configurations/.
  • Do not auto-generate migrations; the initial migration will be created manually later.