好像记得在startup中配置上下文中可以启动失败重试吧,如下!
options.UseSqlServer(sqlConnectionString, retryOptions =>
{
retryOptions.EnableRetryOnFailure(
maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
});
很奇怪,使用这个方式,测试中总是不起作用,15秒左右就报下面的错误:
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server.
while(count<5){
count++;
retry();
}