-
Notifications
You must be signed in to change notification settings - Fork 462
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
Having multiple AddNpgsqlDbContext calls results in second and subsequent contexts using the wrong connection string. #2096
Comments
Looks like this impacts other Aspire EF components as well. |
This looks like a duplicate of npgsql/efcore.pg#2891. cc @roji |
Yep, agree with @eerhardt that this look like a dup of npgsql/efcore.pg#2891. Can you please try creating the NpgsqlDataSource yourself, and then explicitly passing that to AddNpgsqlDbContext rather than having it implicitly taken from DI? That should work around the problem for now (and confirm that we're discussing the same bug). |
I haven't seen this affect other EF components. Can you share a repro of it affecting a non-Npgsql EF component? |
Looking at @mitchdenny's fix in #2097, I don't think this is same issue. The problem is that we are injecting an @roji - is there another way we can work around this bug? (Or even get the underlying bug fixed?) I don't really like that we are registering |
This was my mistake. Only an issue in npgsql. |
In the following playground we initialize multiple Postgres databases for use with EF:
https://github.com/dotnet/aspire/tree/main/playground/PostgresEndToEnd
While debugging I noticed that the database was only being created in the first Postgres server. Upon further inspection it looks like all the various DbContext types that are being injected into the
/
route have the wrong connection string applied (except the first one).This is probably a bug in the registration of the underlying Postgres connection in DI.
The text was updated successfully, but these errors were encountered: