GithubHelp home page GithubHelp logo

Comments (2)

roji avatar roji commented on August 20, 2024

Yes, that is unfortunately the expected behavior; if you use a simple connection string to configure EF, then at the lower Npgsql level the same connection pool is used, and the first time it's initialized (e.g. without NodaTime) is what takes effect for all subsequent use.

The right way forward here is to create two NpgsqlDataSource instances (see the docs) - one with NodaTime, and one without. Then, pass the correct NpgsqlDataSource to EF's UseNpgsql() instead of the connection string. This creates a simple, clear separation between usage/non-usage of NodaTime all the way down the stack.

Another workaround is to simply always turn on NodaTime. Even if you don't use it, it shouldn't interfere with regular DateTime usage.

Finally, you can use different connection strings to have separate connection pools at the lower Npgsql level (as you see to be doing in your demo project). That ensures having different pools, similar to what NpgsqlDataSource achieves, but in a hackier worse way.

I'll go ahead and close this issue as the behavior is by-design, but don't hesitate to post back with more questions etc. I can reopen as necessary.

from efcore.pg.

draudrau avatar draudrau commented on August 20, 2024

Thanks,

I tried this on one of my projects and it seems to work.
Added a data source in the services collection and reused it on health checks and DbContext.

from efcore.pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.