我的实体框架代码存在一个单一问题。我有服务;那天晚上,它对我的数据库进行了一些更新操作。有时候,它几乎是随机的,它会返回错误:
底层提供程序在Open
上失败
阅读时,问题似乎是连接字符串,但我读取的所有提示都已在我的连接字符串中设置。我的连接字符串是:
metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/VEntities.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=192.168.1.100\INSTANCE;
Initial Catalog=dbName;
Persist Security Info=True;
User ID=user;
Password=pwd;
MultipleActiveResultSets=True
你有什么想法吗?它几乎一直在工作,但有时会返回此错误。错误发生后,以下几分钟会显示相同的消息,过了一会儿,它再次运行良好。
向我询问更多细节,如果可以的话,我会把它们交给你。
更新:
这里是stacktrace
System.Data.EntityException: Errore del provider sottostante in Open. —-> System.Data.SqlClient.SqlException: Si è verificato un errore di rete o specifico dell'istanza mentre si cercava di stabilire una connessione con SQL Server. Il server non è stato trovato o non è accessibile. Verificare che il nome dell'istanza sia corretto e che SQL Server sia configurato in modo da consentire connessioni remote. (provider: SQL Network Interfaces, error: 26 - Errore nell'individuazione del server/dell'istanza specificata)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.Open()
in System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
—- Fine della traccia dello stack dell'eccezione interna —-
in System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
in System.Data.EntityClient.EntityConnection.Open()
in System.Data.Objects.ObjectContext.EnsureConnection()
in System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
in xxx.yyy.kkk(String[] array, String storeid, Int32& idimp, DateTime& datelast)