Question

In my old project with .Net Framework use from

 using System.Data.SqlClient;

and

if (ex.GetType() == typeof(SqlException))
{
    return ErrorMessage((SqlException)ex);
}

and now in .NET CORE Does not know Code above

How to use typeof(SqlException) in .NET CORE?

1
2
11/24/2018 9:50:40 AM

Accepted Answer

In .Net Core version, you need to install this package before using it: Microsoft.EntityFrameworkCore.SqlServer

Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 2.1.4

try
{
    // code goes here...    
}
catch (SqlException sqlEx)
{
    // code goes here...
}
catch (Exception ex)
{
    // other exception...
}
1
11/24/2018 9:48:28 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow