Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npgsql ef integration doesn't provide a callback that accepts an IServiceProvider #7016

Open
1 task done
aaronpowell opened this issue Jan 3, 2025 · 3 comments · May be fixed by #7017
Open
1 task done

npgsql ef integration doesn't provide a callback that accepts an IServiceProvider #7016

aaronpowell opened this issue Jan 3, 2025 · 3 comments · May be fixed by #7017
Labels
area-integrations Issues pertaining to Aspire Integrations packages postgres Issues related to Postgres integrations
Milestone

Comments

@aaronpowell
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm porting a codebase to use .NET Aspire and the way that it configures the DbContext is that it uses the callback that takes an IServiceProvider and the options builder: https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.entityframeworkservicecollectionextensions.adddbcontext?view=efcore-9.0#microsoft-extensions-dependencyinjection-entityframeworkservicecollectionextensions-adddbcontext-1(microsoft-extensions-dependencyinjection-iservicecollection-system-action((system-iserviceprovider-microsoft-entityframeworkcore-dbcontextoptionsbuilder))-microsoft-extensions-dependencyinjection-servicelifetime-microsoft-extensions-dependencyinjection-servicelifetime)

Aspire doesn't provide access to this, only to the one that takes the DbContextOptionsBuilder, which means that we have to refactor how things are configured.

Expected Behavior

If the Aspire integration is going to "shadow" the native integration, it should match the API surface area.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

@aaronpowell
Copy link
Contributor Author

This is also a problem with the MySQL integration

@DamianEdwards
Copy link
Member

IIUC this is by design. We purposely don't try to provide top-level method overloads for all scenarios when using EF Core. For advanced cases, you should call the standard EF Core method overload you want, and then call EnrichNpgslDbContext to add the Aspire goodness.

/Cc @eerhardt

@eerhardt
Copy link
Member

eerhardt commented Jan 9, 2025

We purposely don't try to provide top-level method overloads for all scenarios when using EF Core.

Correct. See Redesign EF components public API (dotnet/aspire#1403)

@davidfowl davidfowl added area-integrations Issues pertaining to Aspire Integrations packages postgres Issues related to Postgres integrations and removed untriaged New issue has not been triaged labels Jan 13, 2025
@davidfowl davidfowl added this to the Backlog milestone Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages postgres Issues related to Postgres integrations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants