错误:在IIS中使用EntityFramework在打开时基础提供程序失败

时间:2018-08-17 09:15:54

标签: c# sql-server entity-framework iis

根据下面的堆栈跟踪,我遇到间歇性错误。我将C#实体框架与在单独的服务器计算机上运行的SQL Server 2012 Enterprise结合使用。我可以使用开发机上的SSMS连接并查询数据库。

就我而言,它仅在部署到IIS 7.5时发生。一切都在本地运行良好(在Visual Studio 2015/2017下)。这是.Net Framework 4.7.1

  

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40-无法打开与SQL Server的连接)StackTrace:位于System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,SqlCredential凭据,对象providerInfo,String newPassword,SecureString newSecurePassword,布尔值redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,DbConnectionPool池,字符串accessToken,布尔值applyTransientFaultHandling,SqlAuthenticationProviderManager sqlAuthProviderManager)位于System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey池密钥,对象ConnectionConnectionOptionsing System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池,DbConnection owningObject,DbConnectionOptions选项,DbConnectionPoolKey poolKey,DbConne中的userOptions) System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owneringObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)处System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owneringObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnectionBase)在System.DataProvider中。 DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal&connection),位于System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionsSource,{D1Connection} ,DbConnectionInternal&connection),位于System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection externalConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource 1重试,DbConnecti System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1重试)上的onOptions userOptions),System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(位于System.Data.SqlClient.SqlConnection.Open()处在System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 2操作处执行DbConnection t,DbConnectionInterceptionContext c),在System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher处执行TInterceptionContext拦截上下文,执行动作1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action 3)在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy。<> c__DisplayClass1.b__0()在System.Data.Entity.Core.EntityClient.EntityConnection.b__2()处的.Open(DbConnection连接,DbInterceptionContext拦截上下文)。 SqlServer.DefaultSqlExecutionStrategy.Execute [TResult](Func`1操作),位于System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action操作),位于System.Data.Entity.Core.EntityClient.EntityConnection.Open()

连接字符串:

3 executing, Action

您能帮我解决问题吗?

谢谢大家

0 个答案:

没有答案