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

Add warning for data source gotcha in NetTopologySuite docs #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

douglasg14b
Copy link

@douglasg14b douglasg14b commented Dec 29, 2023

We got hung up on this one for quite a while, it's an easy gotcha to run into if you are setting up NetTopologySuite in an existing application that obtains the connection string via DI inside of the configuring callback of AddDbContext.

Setting up the data source inside of the OnConfiguring callback causes the dependencies of the DbContextOptions to be different every time, causing a new ServiceProvider to be made for each DbContext which will eventually warn/error with the LogManyServiceProvidersCreated error in EF Core.

Please advise preferred verbiage and location.

@roji
Copy link
Member

roji commented Dec 29, 2023

@douglasg14b the general idea seems to be covered in the basic usage docs:

You typically build a single data source, and then use that instance throughout your application

However, it's true that lots of people have run into this problem.

I think a better way here is to add a sample in the basic usage page specifically for DI with AddDbContext, plus a warning there. Then, from the various plugin pages, we can link to the part of the basic usage page. What do you think?

@douglasg14b
Copy link
Author

@roji The quote covers this only after one is knowledgeable about the problem IMHO. This is an unexpected side effect that violates that "rule", but not in a way that is obvious or intentional.

Which is why the suggested warning to avoid the pitfall.

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.

2 participants