我正在通过gatling性能工具测试我的多个用户的应用程序。当它为同时用户点击登录方法时,一些用户成功登录但是对于某些用户我得到“基础提供程序在打开时失败”。错误。 下面是堆栈跟踪:
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
在System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectContext.CreateFunctionObjectResult [TElement](EntityCommand entityCommand,ReadOnlyMetadataCollection 1 entitySets, EdmType[] edmTypes, MergeOption mergeOption)
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, MergeOption mergeOption, ObjectParameter[] parameters)
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ObjectParameter[] parameters)
at Pals.Entities.PalsEntities.sp_FetchVinStatusForAdminCountModifiedAsn(String dealerid, String oemid, String terminalId, Nullable
1 fromDate,Nullable 1 toDate, String onHoldDisplayFlag)
at Portal.Business.Implementation.VinStatusCountAdmin.<>c__DisplayClass1.<FetchVinStatusForAdminCountAsn>b__0()
at Microsoft.Practices.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func
1 func)
在Portal.Business.Implementation.VinStatusCountAdmin.FetchVinStatusForAdminCountAsn(String dealerId,String oemId,String terminalId,DateTime fromDate,DateTime toDate,String onHoldDisplyaFlag)
在Portal.Business.Managers.DashBoardManager.GetVinStatusCountForAdmin(String dealerId,String oemId,String terminalId,DateTime fromDate,DateTime toDate,String boardStatus,String onHoldDisplayFlag)
在Portal.Business.Managers.DashBoardManager.GetDashBoardParallel(SimpleSearch objdao,String boardStatus)
at Pals.Web.Controllers.SearchController.LoadDashBoardParallel(String dealerId,String shipperId,String terminalId,String fromDate,String toDate,String boardStatus)
在lambda_method(Closure,ControllerBase,Object [])
在System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary 2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2个参数)
在System.Web.Mvc.ControllerActionInvoker。&lt;&gt; c__DisplayClass15。&lt; InvokeActionMethodWithFilters&gt; b__12()
在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter过滤器,ActionExecutingContext preContext,Func 1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1过滤器,ActionDescriptor actionDescriptor,IDictionary`2参数)
在System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,String actionName)
我在我的应用程序中使用entityframework。
答案 0 :(得分:0)
(假设您使用的是EF6)
您是否在EF配置中指定了SqlAzureExecutionStrategy
?
如果没有(或者你不知道我在说什么)那么你需要在与DbContext
相同的项目中创建一个继承DbConfiguration
的类,并在其中构造函数,调用SetExecutionStrategy
受保护的方法,如下所示:
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.SqlServer;
namespace MyNamespace
{
public class MyConfiguration : DbConfiguration
{
public MyConfiguration()
{
SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy());
}
}
}
// from http://msdn.microsoft.com/en-us/library/dn456835.aspx
您可以使用SqlAzureExecutionStrategy
的配置来设置重试限制,超时等内容。