Skip to content

fix(deps): move the PgSql and MsSql EF providers onto the EF Core 8 line - #129

Merged
MusaMisto merged 1 commit into
mainfrom
fix/ef-core-8-providers
Aug 31, 2026
Merged

fix(deps): move the PgSql and MsSql EF providers onto the EF Core 8 line#129
MusaMisto merged 1 commit into
mainfrom
fix/ef-core-8-providers

Conversation

@MusaMisto

Copy link
Copy Markdown
Member

Root cause

The 8.0.1 image CrashLoopBackOffs at startup, in MigrateDatabase:

System.TypeLoadException: Could not load type
'Microsoft.EntityFrameworkCore.Storage.IRelationalValueBufferFactoryFactory'
from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=8.0.24.0'

That type was removed in EF Core 7. The projects moved to net8.0 in d48988f (2026-02-12) and most of the EF stack came along — Design 8.0.24, Pomelo 8.0.3, EFCore.NamingConventions 8.0.3 — but two providers were left on the EF Core 5 line, calling an API that no longer exists.

Project Package Before After
SW.Mtm.PgSql Npgsql.EntityFrameworkCore.PostgreSQL 5.0.10 8.0.11
SW.Mtm.MsSql Microsoft.EntityFrameworkCore.SqlServer 5.0.11 8.0.24

SqlServer is pinned to 8.0.24 so it matches the already-pinned Microsoft.EntityFrameworkCore.Design and keeps Relational on a single patch level. Npgsql 8.0.11 is the newest 8.0.x.

Blast radius

This blocked every deployment, not just playground — all six live releases (funride, kwickbox, tamweelna × staging/production) run dbType: PgSql. They are unaffected today only because they still run the 6.0.8 image, which predates the net8.0 migration.

⚠️ Not taking Dependabot #110 / #111

#110 proposes Npgsql → 9.0.4 and #111 Pomelo → 9.0.0. Both are EF Core 9 against an EF Core 8 app — the same major-version mismatch as #117/#118 (.NET 9). They should be closed, or the whole EF stack moved to 9 together.

Verification — A/B against a real PostgreSQL 16, identical environment

Image Result
ghcr.io/simplify9/mtm:8.0.1 (deployed today) TypeLoadException, process dies
this build ✅ starts and stays up

The fixed image did real database work, not just "didn't crash":

  • created the target database (it did not exist)
  • ran migrations — 9 tables in the mtm schema, including _ef_migrations_history, account, tenant, refresh_token, otp_token
  • serves HTTP (404 on unmapped paths, i.e. the host is responding)
  • zero errors in the log (the single "error-ish" line is the sensitive-data-logging warning)

Unit tests pass (1/1) under mcr.microsoft.com/dotnet/sdk:8.0.

After merge

CI publishes 8.0.2. That is the first version that both routes through Gateway API and actually boots — the one downstream callers (including funride-mtm) should pin.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VHkpqv6dB6wjALyFe9ocMU

The 8.0.1 image CrashLoopBackOffs at startup:

  System.TypeLoadException: Could not load type
  'Microsoft.EntityFrameworkCore.Storage.IRelationalValueBufferFactoryFactory'
  from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=8.0.24.0'

That type was removed in EF Core 7. The projects moved to net8.0 in
d48988f (2026-02-12) and most of the EF stack came with them — Design
8.0.24, Pomelo 8.0.3, EFCore.NamingConventions 8.0.3 — but two providers
were left on the EF Core 5 line and call into an API that no longer exists:

  SW.Mtm.PgSql  Npgsql.EntityFrameworkCore.PostgreSQL     5.0.10 -> 8.0.11
  SW.Mtm.MsSql  Microsoft.EntityFrameworkCore.SqlServer   5.0.11 -> 8.0.24

SqlServer is pinned to 8.0.24 so it matches the already-pinned
Microsoft.EntityFrameworkCore.Design and keeps Relational on one patch
level. Npgsql 8.0.11 is the newest 8.0.x.

This blocked every deployment, not just playground: all six live releases
(funride, kwickbox, tamweelna x staging/production) run dbType=PgSql. They
are unaffected today only because they still run the 6.0.8 image, which
predates the net8.0 migration.

NOT taking Dependabot #110 (Npgsql -> 9.0.4) or #111 (Pomelo -> 9.0.0):
both are EF Core 9 against an EF Core 8 app, the same major-version
mismatch as #117/#118.

Verified against a real PostgreSQL 16 container, same env for both images:
  ghcr.io/simplify9/mtm:8.0.1  -> TypeLoadException, process dies
  this build                    -> migrations run, 9 tables created in the
                                   mtm schema incl. _ef_migrations_history,
                                   app serves HTTP, zero errors in the log
Unit tests pass (1/1) under the dotnet/sdk:8.0 image.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHkpqv6dB6wjALyFe9ocMU
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 27 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: simplify9/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e87cc03f-9d28-4802-a49a-b19529addfa8

📥 Commits

Reviewing files that changed from the base of the PR and between fc57bf5 and 7a3d4d3.

📒 Files selected for processing (2)
  • SW.Mtm.MsSql/SW.Mtm.MsSql.csproj
  • SW.Mtm.PgSql/SW.Mtm.PgSql.csproj

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MusaMisto
MusaMisto merged commit 332b7dc into main Aug 31, 2026
5 checks passed
MusaMisto added a commit that referenced this pull request Sep 1, 2026
…ain (#131)

Production login returns HTTP 500:

  InvalidCastException: Reading as 'IEnumerable<ProfileDataItem>' is not
  supported for fields having DataTypeName 'jsonb'
  ---> NotSupportedException: Type 'IEnumerable`1' required dynamic JSON
  serialization, which requires an explicit opt-in; call 'EnableDynamicJson'

Regression from #129, which moved Npgsql 5.0.10 -> 8.0.11 to fix the EF Core
TypeLoadException. Npgsql 8 removed the implicit dynamic JSON serializer:
mapping an arbitrary POCO collection to a json/jsonb column now requires
EnableDynamicJson() on the data source. Three properties rely on it via
StoreAsJson() — Tenant.ProfileData, TenantMembership.ProfileData and
Account.ProfileData — and account.profile_data is jsonb in production.

The blast radius is wider than login: UseApiKeyAsRequestContext materialises
Account on every apikey-authenticated request, so ANY such request 500s.

Startup.cs now builds a single NpgsqlDataSource with EnableDynamicJson() and
hands it to UseNpgsql. It is built once outside the AddDbContext lambda —
NpgsqlDataSource owns the connection pool, so constructing one per DbContext
instance would leak pools.

Verified A/B against the REAL production database, same request, same data:

  ghcr.io/simplify9/mtm:8.0.3   GET /api/accounts   -> 500  (8 exceptions)
                                POST .../login      -> 500
  this build                    GET /api/accounts   -> 200  (0 exceptions,
                                                      real account data)
                                POST .../login      -> 400  (handler reached,
                                                      bad password rejected)

No schema changes were applied during the test — the 2021 migrations are
already present, so startup migration is a no-op.


Claude-Session: https://claude.ai/code/session_01VHkpqv6dB6wjALyFe9ocMU

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant