【发布时间】:2018-11-24 09:33:50
【问题描述】:
在我使用 .Net Framework 的旧项目中使用
using System.Data.SqlClient;
和
if (ex.GetType() == typeof(SqlException))
{
return ErrorMessage((SqlException)ex);
}
现在在 .NET CORE 中不知道上面的代码
如何在.NET CORE 中使用typeof(SqlException)?
【问题讨论】:
-
这将在 .NET Core 中编译得很好。您可能没有将
System.Data.SqlClient包添加到您的项目中。否则,请提供您得到的确切错误消息,以及实际编译它的其余代码,而不是 sn-p。
标签: exception asp.net-core exception-handling entity-framework-core ef-core-2.1