Summary
Argus.Sync.EntityFramework is named for EF Core (which is provider-agnostic) but is currently wired specifically to PostgreSQL. EF Core supports many providers — SQLite, SQL Server, MySQL/MariaDB, etc. — and the bulk of the backend is already provider-neutral, so opening it up is a contained change.
What is already provider-agnostic
CardanoDbContext, EfBlockUnitOfWork, and EfBlockUnitOfWorkFactory use only EF Core APIs (SaveChanges, transactions, the change-tracker) — no Npgsql types.
- Caveat:
EfBlockUnitOfWork sets Database.AutoSavepointsEnabled = false. That is a generic EF property, but the motivation was an Npgsql quirk (auto-savepoints tripping under repeated same-transaction SaveChanges). Worth confirming the value is correct/harmless on other providers.
What is Postgres-specific today
- Registration —
EfServiceCollectionExtensions.cs hardcodes options.UseNpgsql(...) (one line).
- Single-instance lock —
PostgresSingleInstanceLockWorker is entirely NpgsqlConnection + pg_advisory_lock / pg_advisory_unlock. This is the only genuinely DB-specific component.
- Package dependency — pulls
Npgsql.EntityFrameworkCore.PostgreSQL.
Proposed approach
- Pluggable provider: add a generic registration that takes the provider setup, e.g.
AddCardanoEntityFrameworkIndexer<TContext>(config, Action<DbContextOptionsBuilder> configureProvider), and keep AddCardanoPostgresIndexer<T> as a thin convenience wrapper (configureProvider = o => o.UseNpgsql(...)) so current behavior is unchanged.
- Pluggable lock: the single-instance lock already sits behind
ISingleInstanceLock (core), with Postgres + Mongo implementations. For a new EF provider, either:
- supply a native lock (SQL Server
sp_getapplock, MySQL GET_LOCK, …), or
- provide a generic EF lease-lock (a
ReducerLocks row with atomic upsert + heartbeat, like the Mongo lease) as a provider-neutral default — less ideal than native advisory locks, but works on any provider.
- Packaging decision: keep
Argus.Sync.EntityFramework generic with Postgres as a supported provider, vs. split the Npgsql dependency into a separate Argus.Sync.EntityFramework.Postgres.
Scope note
The unit of work and DbContext are free; the real per-provider cost is the single-instance lock (plus verifying the savepoint setting). Ship Postgres as the reference implementation and document "bring your own EF provider."
Summary
Argus.Sync.EntityFrameworkis named for EF Core (which is provider-agnostic) but is currently wired specifically to PostgreSQL. EF Core supports many providers — SQLite, SQL Server, MySQL/MariaDB, etc. — and the bulk of the backend is already provider-neutral, so opening it up is a contained change.What is already provider-agnostic
CardanoDbContext,EfBlockUnitOfWork, andEfBlockUnitOfWorkFactoryuse only EF Core APIs (SaveChanges, transactions, the change-tracker) — no Npgsql types.EfBlockUnitOfWorksetsDatabase.AutoSavepointsEnabled = false. That is a generic EF property, but the motivation was an Npgsql quirk (auto-savepoints tripping under repeated same-transactionSaveChanges). Worth confirming the value is correct/harmless on other providers.What is Postgres-specific today
EfServiceCollectionExtensions.cshardcodesoptions.UseNpgsql(...)(one line).PostgresSingleInstanceLockWorkeris entirelyNpgsqlConnection+pg_advisory_lock/pg_advisory_unlock. This is the only genuinely DB-specific component.Npgsql.EntityFrameworkCore.PostgreSQL.Proposed approach
AddCardanoEntityFrameworkIndexer<TContext>(config, Action<DbContextOptionsBuilder> configureProvider), and keepAddCardanoPostgresIndexer<T>as a thin convenience wrapper (configureProvider = o => o.UseNpgsql(...)) so current behavior is unchanged.ISingleInstanceLock(core), with Postgres + Mongo implementations. For a new EF provider, either:sp_getapplock, MySQLGET_LOCK, …), orReducerLocksrow with atomic upsert + heartbeat, like the Mongo lease) as a provider-neutral default — less ideal than native advisory locks, but works on any provider.Argus.Sync.EntityFrameworkgeneric with Postgres as a supported provider, vs. split the Npgsql dependency into a separateArgus.Sync.EntityFramework.Postgres.Scope note
The unit of work and DbContext are free; the real per-provider cost is the single-instance lock (plus verifying the savepoint setting). Ship Postgres as the reference implementation and document "bring your own EF provider."