DatabaseFacade.CanConnect doesn't actually check anything
See original GitHub issueDatabaseFacade.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:
- Created 4 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m gonna try repro the other issue again on 2.2 in the coming week, I’ll keep you posted
I don’t have any significant pushback against
SELECT 1
.