Skip to content

Split EF Core integration into StrEnum.Npgsql.EntityFrameworkCore#3

Merged
dmytro-khmara merged 1 commit intomasterfrom
split-out-ef-core
Apr 26, 2026
Merged

Split EF Core integration into StrEnum.Npgsql.EntityFrameworkCore#3
dmytro-khmara merged 1 commit intomasterfrom
split-out-ef-core

Conversation

@dmytro-khmara
Copy link
Copy Markdown
Member

@dmytro-khmara dmytro-khmara commented Apr 26, 2026

Summary

Breaking change splitting StrEnum.Npgsql into two packages — driver-level Postgres-enum support stays here; EF Core integration moves to a new package, StrEnum.Npgsql.EntityFrameworkCore (separate PR).

What changed in StrEnum.Npgsql

  • Public surface narrowed to NpgsqlDataSourceBuilder.MapStringEnum<T> — the wire-level resolver-factory + converter pair that was already here. Overloads for INpgsqlTypeMapper and NpgsqlSlimDataSourceBuilder mirror Npgsql's own MapEnum<T> shape.
  • Removed all EF Core types — ModelBuilderExtensions, PropertyBuilderExtensions, DbContextOptionsBuilderExtensions, the value-converter selector trio, and the StringEnumPropertyValueConverter. They're moving to StrEnum.Npgsql.EntityFrameworkCore alongside a new IRelationalTypeMappingSourcePlugin that finally closes the wire-binding gap end-to-end (tracked in the sibling PR).
  • Dependency dropped: Npgsql.EntityFrameworkCore.PostgreSQLNpgsql. Raw Npgsql / Dapper consumers no longer pay an EF Core tax.
  • Targets: net6.0;net7.0;net8.0;net9.0;net10.0net8.0;net9.0;net10.0. The PgTypeInfoResolverFactory API is Npgsql 8+, so older targets weren't getting the resolver anyway.
  • InternalsVisibleTo("StrEnum.Npgsql.EntityFrameworkCore") so the EF wrapper can reuse PostgresNaming and StringEnumLabels without promoting them to public API.

Migration for consumers

Anyone currently using EF Core needs to install StrEnum.Npgsql.EntityFrameworkCore instead. The model/property/options-builder API is unchanged in shape; the EF integration just now sits in the right package.

New integration tests

A Testcontainers-backed integration project verifies the wire-level resolver round-trips a StringEnum<T> against a real Postgres enum column via raw Npgsql commands. Wired into build.yml as a separate integration-tests job (Docker on the GitHub runner; the existing Docker-based unit-test job stays unchanged).

Versioning

This PR is the basis of StrEnum.Npgsql 2.0.

Test plan

  • dotnet test — 10 unit + 1 integration round-trip pass on net10.0
  • Confirm Npgsql.EntityFrameworkCore.PostgreSQL no longer appears in the package's transitive deps
  • Smoke-test the new MapStringEnum<T> against a fresh consumer using the unreleased package

This is a breaking change. StrEnum.Npgsql now ships only the wire-level
Postgres-enum support for the Npgsql ADO.NET driver. EF Core integration
moves to a new package, StrEnum.Npgsql.EntityFrameworkCore, mirroring how
the Npgsql ecosystem itself splits Npgsql.NetTopologySuite (driver) from
Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite (EF wrapper).

Removed:
- ModelBuilderExtensions, PropertyBuilderExtensions,
  DbContextOptionsBuilderExtensions
- StringEnumValueConverter, StringEnumValueConverterSelector,
  ChainedValueConverterSelectorDecorator, StringEnumPropertyValueConverter
- All EF Core-shaped unit tests

Kept:
- NpgsqlDataSourceBuilderExtensions.MapStringEnum<T> (now the public
  surface), with overloads for INpgsqlTypeMapper to mirror MapEnum<T>
- The wire-level resolver / converter pair under Internal/

Added:
- Testcontainers-based integration test that round-trips a StringEnum<T>
  against a real Postgres enum column via raw Npgsql commands
- Integration-tests CI job that runs against Docker on the GitHub runner

Other changes:
- Dependency narrowed from Npgsql.EntityFrameworkCore.PostgreSQL to Npgsql
- Targets narrowed from net6.0..net10.0 to net8.0..net10.0 (the
  PgTypeInfoResolverFactory API is Npgsql 8+)
- InternalsVisibleTo("StrEnum.Npgsql.EntityFrameworkCore") so the EF
  wrapper can reuse PostgresNaming and StringEnumLabels without
  promoting them to public API
@dmytro-khmara dmytro-khmara merged commit eecf118 into master Apr 26, 2026
2 checks passed
@dmytro-khmara dmytro-khmara deleted the split-out-ef-core branch April 26, 2026 23:00
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