I'm using Entity Framework with C# and I need to be able to check weather the database is connected and in case it isn't throw an Exception so the application doesn't crash. Any ideas? thank you!
EF Database not Connected Exception
375 views Asked by user3740654 At
2
There are 2 answers
0
On
If the DB connection is valid:
DatabaseContext.Exists();
If a server machine is up, use Ping.Send
Method:
Ping.Send Method (String)
A simple implementation would be something like this