In normal entity framework I am able to check the database connectivity using dbContext.Database.Exists()
but in Entity Framework Core it is not there. What is the alternative of dbContext.Database.Exists()
in Entity Framework Core?
Open the edmx (go to properties, the connection string should be blank), close the edmx file again. Open the app. config and uncomment the connection string (save file) Open the edmx, go to properties, you should see the connection string uptated!!
You can determine whether or not the database is available and can be connected to with the CanConnect()
method:
if (dbContext.Database.CanConnect())
{
// all good
}
You can use CanConnectAsync()
for asynchronous operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With