SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接 返回

public class BaseRepository<T> : SimpleClient<T>, IBaseRepository<T> where T : class, new()
{
public BaseRepository(ISqlSugarClient context = null) : base(context)
{
base.Context = DbScoped.SugarScope;
}
}
services.AddSqlSugar(new IocConfig()
{
ConfigId = "Equipment",
ConnectionString = configuration[$"DataBase:{vIocDbType}:JYT_Equipment_ConnString"],
DbType = vIocDbType,
IsAutoCloseConnection = true
});
//AOP 统一配置 禁止循环,只能声名一次
services.ConfigurationSugar(db =>
{
//里面可以循环
db.GetConnection("Equipment").Aop.OnLogExecuting = (sql, p) =>
{
#if DEBUG
//ConsoleColor currentForeColor = Console.ForegroundColor;
//Console.ForegroundColor = ConsoleColor.Blue;
//Console.WriteLine(sql);
//Console.ForegroundColor = currentForeColor;
#endif
};
//里面可以循环
db.GetConnection("Equipment").Aop.OnError = (exp) =>
{
#if DEBUG
ConsoleColor currentForeColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(exp.Message);
Console.ForegroundColor = currentForeColor;
#endif
};
});
不知道什么原因偶尔会报出这样的错误,“SqlSugar.SqlSugarException: 中文提示 : 连接数据库过程中发生错误,检查服务器是否正常连接”
热忱回答(3)
-
fate sta VIP0
2023/5/17你可以写个可以重现的DEMO,发我 。 或者把报错的异常截图发全0 回复 -
Alazyer VIP0
1周前@fate sta:
关于他提到的这个问题,我也遇到了 类似的情况,麻烦大佬有空看下
0 回复 -
Alazyer VIP0
1周前@Alazyer:
0 回复