- Step-by-step prompts for solution skeleton, domain model, DbContext mappings, application services, UI shell/pages, PDF export, and tests/validation
45 lines
1.4 KiB
Markdown
45 lines
1.4 KiB
Markdown
---
|
|
description: "Implement FinanceDbContext with fluent entity configurations, indexes, relationships, and SQLite connection setup"
|
|
agent: "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.
|
|
|
|
### TransferLink
|
|
- 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.
|