question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DatabaseFacade.CanConnect doesn't actually check anything

See original GitHub issue

DatabaseFacade.CanConnect is supposed to determine whether the database is alive and can be connected to. The default implementation in RelationalDatabaseCreator calls Exists, whose implementation in SqlServer (and Sqlite and Npgsql) is to simply open and close a connection. As far as I’m aware, assuming connection pooling is enabled this doesn’t actually do any sort of communication to the database. We should consider implementing CanConnect by doing a raw SELECT 1 roundtrip, or possibly opening and closing a non-pooled connection.

Note that ASP.NET’s EF health probe is built over this API.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mmisztal1980commented, Oct 13, 2019

I’m gonna try repro the other issue again on 2.2 in the coming week, I’ll keep you posted

0reactions
AndriySvyrydcommented, Oct 21, 2019

I don’t have any significant pushback against SELECT 1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DatabaseFacade.CanConnect doesn't actually check ...
DatabaseFacade.CanConnect is supposed to determine whether the database is alive and can be connected to. The default implementation in ...
Read more >
How to check connection to database in Entity Framework ...
You can determine whether or not the database is available and can be connected to with the CanConnect() method: if (dbContext.Database.
Read more >
DatabaseFacade.CanConnect Method
Determines whether or not the database is available and can be connected to.
Read more >
EF Core — check if DB exists
Asynchronously ensures that the database for the context exists. If it exists, no action is taken. If it does not exist then the...
Read more >
How to verify connection to the database in Entity Framework ...
This article explains how to perform a very simple and lightweight database connection test for an existing database context.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found