Skip to content

refactor(ef): split EntityFramework into a provider-neutral core + Postgres package#179

Merged
Mercurial merged 3 commits into
mainfrom
refactor/ef-core-postgres-split
Jun 20, 2026
Merged

refactor(ef): split EntityFramework into a provider-neutral core + Postgres package#179
Mercurial merged 3 commits into
mainfrom
refactor/ef-core-postgres-split

Conversation

@Mercurial

Copy link
Copy Markdown
Contributor

What

Splits Argus.Sync.EntityFramework into the EF Core ecosystem's shape — a provider-neutral core plus a per-provider package — and refreshes dependencies along the way. Two commits:

  1. chore(deps) — refresh NuGet packages to latest within the net10 line (Microsoft.Extensions.* + EF Core trio → 10.0.9, Npgsql.EFCore → 10.0.2, AspNetCore.OpenApi → 10.0.9, Swashbuckle → 10.2.2, Spectre.Console → 0.57.0, Test.Sdk → 18.6.0, coverlet → 10.0.1). xunit stays on 2.x (no v3 migration); Chrysalis/Utxorpc alpha pins untouched.
  2. refactor(ef) — the package split (below).

The split

Package Role Depends on
Argus.Sync.EntityFramework Provider-neutral EF Core backend: CardanoDbContext, the EF unit-of-work, and the new public AddCardanoEntityFrameworkIndexer<T>(configureProvider) seam Argus.Sync + Microsoft.EntityFrameworkCore.Relational
Argus.Sync.EntityFramework.Postgres (new) PostgreSQL / Npgsql provider: AddCardanoPostgresIndexer<T> (a thin UseNpgsql wrapper) + the advisory single-instance lock Argus.Sync.EntityFramework + Npgsql.EntityFrameworkCore.PostgreSQL

AddCardanoPostgresIndexer is now a small wrapper that (1) builds the UseNpgsql delegate, (2) registers the Postgres lock, (3) calls the core seam. Adding SQLite/SQL Server later is a sibling wrapper over the same seam — this lands the structural half of #178.

The advisory-lock worker is renamed PostgresSingleInstanceLockWorkerPostgresSingleInstanceLock to match the sibling MongoSingleInstanceLock (git tracked it as a rename).

⚠️ Breaking

Consumers of AddCardanoPostgresIndexer must now:

  • add the Argus.Sync.EntityFramework.Postgres package (it pulls in the core transitively), and
  • add using Argus.Sync.EntityFramework.Postgres;.

Acceptable in alpha; suggests a notable bump (e.g. v1.3.0-alpha) at release. The pm2 stability consumers will need the new package on their next bump (not touched here).

Also

  • Fix the commandTimoutcommandTimeout typo on the public registration.
  • Make the core docs provider-neutral ("Postgres schema" → "database schema", etc.).
  • Wire the new package into the Example, Tests (IndexerRegistrationTest, SingleInstanceLockTest), the release.yml + ci.yml pack lists, and the README.

Verification

  • dotnet build -c Release — 0 warnings, 0 errors.
  • dotnet format --verify-no-changes — clean.
  • dotnet test --filter "Category!=Integration&Category!=DataGeneration"22 passed; IndexerRegistrationTest proves AddCardanoPostgresIndexer still wires the EF seam + renamed lock + worker.
  • dotnet pack both EF packages — nuspecs confirm core → Microsoft.EntityFrameworkCore.Relational (no Npgsql); Postgres → Argus.Sync.EntityFramework + Npgsql.

Out of scope

No new provider (SQLite/etc.) and no generic lease-lock — the remaining half of #178 (each non-Postgres provider needs its own ISingleInstanceLock). The CardanoNodeConnection:RollbackBuffer key is unchanged (consistent with Mongo + the live consumers).

🤖 Generated with Claude Code

Mercurial and others added 2 commits June 21, 2026 00:32
Bump Microsoft.Extensions.* and the EF Core trio to 10.0.9, Npgsql.EFCore
to 10.0.2, AspNetCore.OpenApi to 10.0.9, Swashbuckle to 10.2.2,
Spectre.Console to 0.57.0, Test.Sdk to 18.6.0, coverlet.collector to 10.0.1.

All within the net10 line; xunit stays on 2.x (no v3 migration). Chrysalis
and Utxorpc alpha pins and the already-latest Mongo/bench packages unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…stgres package

Argus.Sync.EntityFramework becomes the provider-neutral EF Core backend —
CardanoDbContext, the EF unit-of-work, and a new public
AddCardanoEntityFrameworkIndexer<T>(configureProvider) seam — and now depends
on Microsoft.EntityFrameworkCore.Relational instead of Npgsql. The
PostgreSQL/Npgsql specifics move to a new Argus.Sync.EntityFramework.Postgres
package: AddCardanoPostgresIndexer<T> (a thin UseNpgsql wrapper over the core
seam) plus the advisory-lock worker, renamed PostgresSingleInstanceLockWorker
-> PostgresSingleInstanceLock to match the sibling MongoSingleInstanceLock.

This mirrors the EF Core ecosystem (core + per-provider packages) and makes
adding SQLite/SQL Server later a sibling wrapper. Implements the structural
half of #178.

BREAKING: AddCardanoPostgresIndexer consumers must add the
Argus.Sync.EntityFramework.Postgres package and a
`using Argus.Sync.EntityFramework.Postgres;`.

Also fixes the commandTimeout typo, makes the core docs provider-neutral, and
wires the new package into the Example, Tests, release.yml, ci.yml, and README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 20, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Splits the Entity Framework backend into a provider-neutral core (Argus.Sync.EntityFramework) plus a new Postgres provider package (Argus.Sync.EntityFramework.Postgres), and updates dependency versions and wiring across examples, tests, CI, and release packaging to match the new package layout.

Changes:

  • Introduces AddCardanoEntityFrameworkIndexer<T>(configureProvider) in the core EF package and moves UseNpgsql + advisory-lock wiring into a new Postgres provider package.
  • Renames and relocates the Postgres single-instance lock implementation to the new provider package and updates tests/example accordingly.
  • Updates docs, workflows, and packing lists to include the new package; refreshes shared NuGet package versions.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Argus.Sync.Tests/EndToEnd/SingleInstanceLockTest.cs Updates test to use the new Postgres provider namespace and renamed lock type.
src/Argus.Sync.Tests/EndToEnd/IndexerRegistrationTest.cs Updates DI assertions for the renamed lock type and provider namespace.
src/Argus.Sync.Tests/Argus.Sync.Tests.csproj Adds project reference to the new Postgres provider project.
src/Argus.Sync.Example/Program.cs Switches example registration to Argus.Sync.EntityFramework.Postgres.
src/Argus.Sync.Example/Argus.Sync.Example.csproj Adds project reference to the new Postgres provider project.
src/Argus.Sync.EntityFramework/EfServiceCollectionExtensions.cs Replaces Postgres-specific registration with provider-neutral AddCardanoEntityFrameworkIndexer.
src/Argus.Sync.EntityFramework/EfBlockUnitOfWorkFactory.cs Minor refactor: uses IDbContextTransaction via a namespace import.
src/Argus.Sync.EntityFramework/CardanoDbContext.cs Documentation wording updated to be provider-neutral.
src/Argus.Sync.EntityFramework/Argus.Sync.EntityFramework.csproj Removes Npgsql dependency; references Microsoft.EntityFrameworkCore.Relational for provider-neutral core.
src/Argus.Sync.EntityFramework.Postgres/PostgresSingleInstanceLock.cs Moves/renames the Postgres lock into the provider package namespace.
src/Argus.Sync.EntityFramework.Postgres/PostgresServiceCollectionExtensions.cs Adds new Postgres-specific DI entry point wrapping the provider-neutral seam.
src/Argus.Sync.EntityFramework.Postgres/Argus.Sync.EntityFramework.Postgres.csproj Adds new provider package project referencing core + Npgsql EF provider.
README.md Updates installation and usage instructions to reference the new provider package.
Directory.Packages.props Refreshes centralized package versions (EF Core, Npgsql EF provider, tooling, etc.).
.github/workflows/release.yml Adds packing of the new Postgres provider package.
.github/workflows/ci.yml Includes the new Postgres provider package in CI packing loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +39
/// <item>The fault propagates out of <see cref="Workers.CardanoIndexWorker"/>'s execute loop,
/// which stops the host (the default <see cref="Microsoft.Extensions.Hosting.BackgroundService"/> behavior).</item>
Argus.Sync.EntityFramework, Argus.Sync.EntityFramework.Postgres, and
Argus.Sync.MongoDb were building only transitively (via the Example/Tests
project references) and were absent from Argus.slnx. List all 7 projects so a
solution build compiles every backend in the chosen configuration directly
(they now emit to bin/Release on a Release build instead of bin/Debug).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Mercurial Mercurial merged commit f19b5f3 into main Jun 20, 2026
1 check passed
@Mercurial Mercurial deleted the refactor/ef-core-postgres-split branch June 20, 2026 16:59
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.

2 participants