- Step-by-step prompts for solution skeleton, domain model, DbContext mappings, application services, UI shell/pages, PDF export, and tests/validation
1.4 KiB
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> AccountsDbSet<AccountYear> AccountYearsDbSet<Entry> EntriesDbSet<TransferLink> TransferLinks
Connection
- Accept SQLite connection string via constructor options.
- Default path:
Data Source=duempelkas.dbin the app's base directory.
Entity Configurations (use OnModelCreating with IEntityTypeConfiguration<T> or inline)
Account
Namerequired, max length 200.- Cascade delete → AccountYears.
AccountYear
- Unique index on
(AccountId, Year). OpeningBalancecolumn typedecimal(18,2).- Cascade delete → Entries.
Entry
- Index on
(AccountYearId, Date). Amountcolumn typedecimal(18,2).Typestored as int.- Optional FK to TransferLink (
TransferLinkId), restrict delete.
TransferLink
- Unique index on
SourceEntryId. - Unique index on
TargetEntryId. - Relationships to SourceEntry and TargetEntry with
DeleteBehavior.Restrict.
Notes
- Use separate
IEntityTypeConfiguration<T>classes inPersistence/Configurations/. - Do not auto-generate migrations; the initial migration will be created manually later.