Why does SqlAzureExecutionStrategy not handle error: 19 - Physical connection is not usable

前端 未结 5 503
我在风中等你
我在风中等你 2021-02-04 07:12

Full exception:

System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for de         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 07:55

    My problem was with the time of SqlAzureExecutionStrategy, was stablished in 300 secods (5 minutes) and the operations I was doing took more than 5 minutes:

    Imports System.Data.Entity
    Imports System.Data.Entity.SqlServer
    
    Namespace Models
        Public Class ModelConfiguration
            Inherits DbConfiguration
    
            Sub New()
                ' https://docs.microsoft.com/es-es/ef/ef6/fundamentals/connection-resiliency/retry-logic
    
                ' WebConfig
                Dim AzureBBDD = ConfigurationManager.AppSettings("AzureBBDD").Equals("SI")
    
                ' If AzureBBDD == "SI"
                If (AzureBBDD) Then
                    ' WebConfig, here was the problem, low value in seconds...
                    Dim AzureBBDDMaxTimeSeconds = Integer.Parse(ConfigurationManager.AppSettings("AzureBBDDMaxTimeSeconds"))
                    SetExecutionStrategy("System.Data.SqlClient",
                                     Function()
                                         Return New SqlAzureExecutionStrategy(Integer.MaxValue, TimeSpan.FromSeconds(AzureBBDDMaxTimeSeconds))
                                     End Function)
    
                End If
            End Sub
        End Class
    End Namespace
    

提交回复
热议问题