I have a small situation that rarely occurs but have been tasked with presenting a prettied up check for it.
Currently, if our DB happens to be kicked offline, the system message that gets output is that the standard object has null reference. I could trap this via try/catch block in this one location. However, there can be multiple instances of this.
My main issue is the following: we have a default class we use to call for the DbContext, which is called DatabaseContext.cs. This class inherits DbContext, and in it's constructor has a base call for the connection. See below for how it is called.
public partial class DatabaseContext : DbContext
{
public DatabaseContext()
: base(new OracleConnection(Common.Common.Decrypt(ConfigurationManager.
ConnectionStrings["Site"].ToString())), true)
{
}
Ignore the Decrypt part (we encrypt our Connection String). My question I have is there a way I can trap that call? I thought about doing a try/catch around it, but wasn't really sure about removing it from the base call at the same time. It probably is that simple, but I want to be doubly sure before I remove it and then have issues with it. Thanks.