I am wondering what is the best approach to managing / monitoring a server database connection using Entity Framework.
I know that an EF DB context or object context executes the core bits for you. However, in our scenario, the user can disconnect the network cable from the client or stop the server on the server machine, etc.
DB ↔ Network ↔ Fat Client (EF) Server
Therefore, in the above scenario, if the network goes down and the client tries to perform any operation that requires access to data, there will be an exception (the basic provider has failed to open).
What is the best approach to detect database connection loss so that the client application (where the DB / UoW context, Rep, etc.) can fail gracefully?
One of the solutions that I saw was to open a manual connection to the server database (DBConnection), and then poll the database using a timer in C # and write to the heartbeat table. Then it catches the exception when it occurs. This seems like a massive hack for me.
Any help would be appreciated ... Thanks in advance.
source
share