Skip to content

feat(persistence): EF Core + SQLite persistence layer (#26)#32

Merged
jaybarden1 merged 2 commits into
mainfrom
feature/26-ef-core-sqlite-persistence
May 27, 2026
Merged

feat(persistence): EF Core + SQLite persistence layer (#26)#32
jaybarden1 merged 2 commits into
mainfrom
feature/26-ef-core-sqlite-persistence

Conversation

@jaybarden1

Copy link
Copy Markdown
Contributor

Summary

Implements the full EF Core + SQLite persistence layer described in issue #26. Accounts, sync rules, and all related state now survive app restarts.

Changes

Production

  • 13 strongly-typed value objects (AccountId, DriveId, EmailAddress, LocalSyncPath, etc.) — all readonly record struct(string Value)
  • 8 EF Core entities with IEntityTypeConfiguration<T>, cascade deletes on all child tables, and DateTimeOffset→ticks converters for SQLite compatibility
  • AppDbContext with ApplyConfigurationsFromAssembly + InitialCreate migration
  • SqliteTypeConverters — centralised value converters for all wrapper types and DateTimeOffset variants
  • 6 repository interfaces + implementationsAccountRepository, SyncRuleRepository, SyncedItemRepository, DriveStateRepository, SyncRepository, FileClassificationRuleRepository
  • AppDbContextDesignTimeFactory — enables dotnet ef tooling
  • AccountOnboardingService — replaces the in-memory stub with real IAccountRepository + ISyncRuleRepository persistence; uses BindAsync chain to stay compliant with no-is-matching rule
  • ResultExtensions.BindAsync — new async-binder overload enabling Task<Result<T,E>> chaining without intermediate variables
  • App.axaml.cs — registers IDbContextFactory<AppDbContext> (singleton), all 6 repos (transient), calls Database.Migrate() on startup

Tests

  • New integration test project (AStar.Dev.CloudSyncFunctional.Tests.Integration) with real SQLite :memory: via IClassFixture<DatabaseFixture> and MigrateAsync
  • 21 integration tests across AccountRepository, SyncRuleRepository, DriveStateRepository, and AccountOnboardingService (end-to-end with real DB)
  • Existing 171 unit tests unaffected

Test plan

  • dotnet build — 0 errors, 0 warnings
  • Integration tests — 21/21 pass (real SQLite, MigrateAsync)
  • Unit tests — 171/171 pass
  • Option columns (LastSyncedAt) round-trip correctly via nullable ticks converter
  • Cascade deletes configured: deleting an AccountEntity removes all child rows
  • MigrateAsync runs on startup via App.axaml.cs

Closes #26


🤖 Generated with Claude Code

jaybarden1 and others added 2 commits May 27, 2026 09:47
…#26)

RED commit — stubs throw NotImplementedException; integration tests fail.

Failing tests:
- GivenAnAccountRepository: 4 tests
- GivenASyncRuleRepository: 2 tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add 13 strongly-typed domain value objects (AccountId, DriveId, EmailAddress, etc.)
- Add 8 EF Core entities with IEntityTypeConfiguration, cascade deletes, and DateTimeOffset→ticks converters
- Add AppDbContext with ApplyConfigurationsFromAssembly and InitialCreate migration
- Add SqliteTypeConverters for all value objects and DateTimeOffset variants
- Add 6 repository interfaces + implementations (Account, SyncRule, SyncedItem, DriveState, Sync, FileClassificationRule)
- Add AppDbContextDesignTimeFactory for dotnet-ef tooling
- Replace AccountOnboardingService in-memory stub with real IAccountRepository + ISyncRuleRepository persistence
- Add BindAsync overload to ResultExtensions for async chaining without intermediate variables
- Register IDbContextFactory<AppDbContext> (singleton) and all repositories (transient) in App.axaml.cs
- Call Database.Migrate() on startup
- Add integration test project with DatabaseFixture (MigrateAsync), 21 integration tests across Account, SyncRule, DriveState repositories and AccountOnboardingService

Closes #26

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jaybarden1 jaybarden1 requested a review from a team May 27, 2026 10:43
@github-actions

Copy link
Copy Markdown

Test results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit edf59ff.

@jaybarden1 jaybarden1 enabled auto-merge (squash) May 27, 2026 10:44
@jaybarden1 jaybarden1 merged commit f2000bf into main May 27, 2026
5 of 6 checks passed
@jaybarden1 jaybarden1 deleted the feature/26-ef-core-sqlite-persistence branch May 27, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(persistence): EF Core + SQLite persistence layer

2 participants