如何处理 entity framework 的存储过程异常消息

How to handle store procedure exception message to entity framework

如何捕获 RAISEERROR 或 SQL 2012 - 从 sql 存储过程向 entity framework - 存储过程调用抛出异常?

using (Entities context = new Entities())
{
        IEnumerable<EmployeeDetails> empDetails  =  context. Database.SqlQuery
                                                                      < EmployeeDetails >("exec GetEmployeeData ", null).ToList();
}

尝试/抓住?

using (Entities context = new Entities())
{
    try
    {
        IEnumerable<EmployeeDetails> empDetails  =  context. Database.SqlQuery                                                            <EmployeeDetails>("exec GetEmployeeData ", null).ToList();
    }
    Catch (SqlException ex)
    {
        //Do something
    }
}