从.NetCore2.2 升级到 .NetCore3.1 SqlSugar报错 返回

SqlSugar 老数据
4 2790

SqlSugar.SqlSugarException: English Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)

Chinese Message :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,实在找不到原因请先Google错误信息:A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed).

   at SqlSugar.AdoProvider.GetDataReaderAsync(String sql, SugarParameter[] parameters)

   at SqlSugar.QueryableProvider`1.GetDataAsync[TResult](KeyValuePair`2 sqlObj)

   at SqlSugar.QueryableProvider`1._ToListAsync[TResult]()



connectionString="Data Source=TESTSQL1IRV.iherb.net;Initial Catalog=Test_Toys;User ID=sss;Password=sss88888888;Persist Security Info=True;Connection Timeout=60"


protected SqlSugarClient GetDbContext(string connectionString)

        {

            try

            {

                var dbContext = new SqlSugarClient(new ConnectionConfig()

                {

                    ConnectionString = connectionString,

                    DbType = DbType.SqlServer,

                    InitKeyType = InitKeyType.Attribute,

                    IsAutoCloseConnection = true

                });


                Console.WriteLine($"[BaseSugarRepository] ConnectionString:{connectionString}");


                dbContext.Aop.OnLogExecuting = (sql, pars) =>

                {

                    Console.WriteLine("[BaseSugarRepository] " + sql + "\r\n" + dbContext.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));

                };


                return dbContext;

            }

            catch (Exception ex)

            {

                Console.WriteLine($"[BaseSugarRepository Exception] Message:{ex.Message}, StackTrace:{ex.StackTrace}");

                throw new Exception("Failed to connect database. Please check the connection string and network connection", ex);

            }

        }


热忱回答4

  • "Failed to connect database. Please check the connection string and network connection ,你在3.1写个简单DEMO测试一下,可能和升级关系不大

    0 回复
  • 新建一个3.1项目去测试

    0 回复
  • 还有sqlsugarcore需要同步升级到比较高版本

    0 回复
  • 你先把new sqlconnection(con).open()这个测试通

    0 回复