按异常类型不捕获任何实体数据库错误

时间:2019-04-10 16:00:39

标签: c# entity-framework

如果数据库已关闭,我正在尝试使代码进入休眠状态。一切正常。我正在通过捕获异常来检查数据库是否可用,然后正在检查异常消息。是否有任何方法,例如异常类型,错误号.....

if (ex.Message == "The underlying provider failed on Open." || ex.Message == "A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)")
{
       CheckConnection();
}

0 个答案:

没有答案