Skip to content

Fix playground apps after Npgsql 9 update#7045

Merged
eerhardt merged 2 commits intomicrosoft:mainfrom
eerhardt:WorkaroundNpgsqlMismatch
Jan 9, 2025
Merged

Fix playground apps after Npgsql 9 update#7045
eerhardt merged 2 commits intomicrosoft:mainfrom
eerhardt:WorkaroundNpgsqlMismatch

Conversation

@eerhardt
Copy link
Copy Markdown
Member

@eerhardt eerhardt commented Jan 8, 2025

Npgsql EF requires a matching major version with the Npgsql version being used. There are breaking changes between major versions that don't allow Npgsql EF 8 to load with Npgsql 9, and vice versa.

Workaround this by ensuring that whenever we use Npgsql EF we use a matching Npgsql version.

It looks like the playground tests were disabled in Improve auto-forwarding for GitHub Codespaces and devcontainers. (dotnet/aspire#6780).

Comment thread Directory.Packages.props
<ProjectReference Include="..\TestShop.ServiceDefaults\TestShop.ServiceDefaults.csproj" />

<!-- Npgsql EF needs to match the same major version as the underlying Npgsql assemblies. -->
<PackageReference Include="Npgsql.DependencyInjection" VersionOverride="$(Npgsql8Version)" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: should we consider doing the override in a single place (like a directory.build.props so all of these testshop projects can benefit) and that way we reduce the number of places that need to be updated come .net 10?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should only override the PackageRefernce if the app is also referencing Npgsql EF Core. There are only a handful of playground apps use it. We can't do it in a single place without affecting the projects that don't want it.

The real problem here is transitive pinning. Since most projects want Npgsql v9, we use that in our Directory.Packages.props (even when targeting net8 - see #6946). But when an app is targeting net8 -> it needs EF Core 8. And if it uses EF Core 8 -> it needs Ngpsql 8.

Copy link
Copy Markdown
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

Left only NITs, non are blocking, more just questions, so this LGTM.

Npgsql EF requires a matching major version with the Npgsql version being used. There are breaking changes between major versions that don't allow Npgsql EF 8 to load with Npgsql 9, and vice versa.

Workaround this by ensuring that whenever we use Npgsql EF we use a matching Npgsql version.
@eerhardt eerhardt force-pushed the WorkaroundNpgsqlMismatch branch from cfe46ea to 565f11c Compare January 9, 2025 21:18
@eerhardt eerhardt enabled auto-merge (squash) January 9, 2025 21:48
@eerhardt eerhardt merged commit ac38396 into microsoft:main Jan 9, 2025
@eerhardt eerhardt deleted the WorkaroundNpgsqlMismatch branch January 9, 2025 23:33
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 9, 2025
@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants