应用程序的SQL Server连接超时问题

时间:2019-03-01 18:14:09

标签: c# asp.net sql-server entity-framework ado.net

我们有一个使用SQL Server作为数据库在.NET中构建的应用程序,我们在其中使用EF(Entity Framework)进行INSERT操作,而使用ADO.NET进行GET操作。

我们最近在应用程序中遇到了一个问题,即有时我们无法执行INSERT操作(超时除外)。我们能够从应用程序中获取数据,但无法插入任何数据。

要解决此问题,我们需要每次都重新启动SQL Server实例。但是又过了一两天,同样的情况出现了,我们无法执行INSERT操作

注意:在ConnectionString中,我们将Connection TimeOut值保持为180。

请找到堆栈跟踪错误:

    MIRRA.CareManagement.UM.Authorization.Exceptions.BusinessException:
    at MIRRA.CareManagement.UM.Authorization.Business.Authorization.AuthorizationManager.SaveAuthorization (MIRRA.CareManagement.UM.Authorization.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
   at MIRRA.CareManagement.UM.Authorization.Web.Controllers.UM.Authorization.AuthorizationController.SaveCalypsoLyteAuthorization (MIRRA.CareManagement.UM.Authorization.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
Inner exception System.Data.Entity.Infrastructure.DbUpdateException handled at MIRRA.CareManagement.UM.Authorization.Business.Authorization.AuthorizationManager.SaveAuthorization:
   at MIRRA.CareManagement.UM.Authorization.DataRepository.EFRepository.EFGenericRepository`1.Save (MIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: D:\Agents\UM\UM-Portal-01\_work\9\s\MIRRA.UM.Authorization.Data\EFRepository\EFGenericRepository.csMIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 435)
   at MIRRA.CareManagement.UM.Authorization.DataRepository.EFRepository.Authorization.AuthorizationRepository.SaveAuthorization (MIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: D:\Agents\UM\UM-Portal-01\_work\9\s\MIRRA.UM.Authorization.Data\EFRepository\Authorization\AuthorizationRepository.csMIRRA.CareManagement.UM.Authorization.DataRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 180)
Inner exception System.Data.Entity.Core.UpdateException handled at MIRRA.CareManagement.UM.Authorization.DataRepository.EFRepository.EFGenericRepository`1.Save:
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute (EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Internal.InternalContext.SaveChanges (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
Inner exception System.Data.SqlClient.SqlException handled at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update:
   at System.Data.SqlClient.SqlConnection.OnError (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.TdsParser.TryRun (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlDataReader.get_MetaData (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.SqlClient.SqlCommand.ExecuteReader (System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
   at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update (EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
Inner exception System.ComponentModel.Win32Exception handled at System.Data.SqlClient.SqlConnection.OnError:

请建议是否有人遇到相同的问题。

0 个答案:

没有答案