private static string ReportSqlErrors(SqlException exception) { SqlError[] errors = new SqlError[exception.Errors.Count]; exception.Errors.CopyTo(errors, 0); // If there is only one simple error, it will be reported in a single line (most likely) // to improve integration with Visual Studio. return(string.Join(Environment.NewLine, errors.Select(ReportSqlError))); }