2013-09-21 26 views
1

未處理我與C#,ASP,.NET,Visual Studio中,或Azure的經驗很少。我有在部署到Azure的(我還是不明白這個過程中)正在執行罰款的Web應用程序,但是當我運行調試 - >啓動調試在Visual Studio 2012,我得到這個錯誤:System.Data.EntityException是由用戶代碼

System.Data.EntityException was unhandled by user code 
    HResult=-2146233087 
    Message=The underlying provider failed on Open. 
    Source=System.Data.Entity 
    StackTrace: 
     at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) 
     at System.Data.EntityClient.EntityConnection.Open() 
     at System.Data.Objects.ObjectContext.EnsureConnection() 
     at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) 
     at System.Data.Entity.Internal.InternalContext.SaveChanges() 
     at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() 
     at System.Data.Entity.DbContext.SaveChanges() 
     at Awesomeness.Core.BaseController.AddLog(String key, String message) in c:\Users\zack\Code\Awesomeness Reminders\AwesomenessWeb\AwesomenessWeb\Core\BaseController.cs:line 76 
     at Awesomeness.Core.BaseController.OnActionExecuting(ActionExecutingContext filterContext) in c:\Users\zack\Code\Awesomeness Reminders\AwesomenessWeb\AwesomenessWeb\Core\BaseController.cs:line 26 
     at System.Web.Mvc.Controller.System.Web.Mvc.IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) 
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) 
     at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() 
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) 
     at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) 
    InnerException: System.Data.SqlClient.SqlException 
     HResult=-2146232060 
     Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 
     Source=.Net SqlClient Data Provider 
     ErrorCode=-2146232060 
     Class=20 
     LineNumber=0 
     Number=2 
     Server="" 
     State=0 
     StackTrace: 
      at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
      at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) 
      at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) 
      at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) 
      at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) 
      at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) 
      at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 
      at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) 
      at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
      at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
      at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) 
      at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) 
      at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) 
      at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
      at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
      at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) 
      at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 
      at System.Data.SqlClient.SqlConnection.Open() 
      at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) 
     InnerException: System.ComponentModel.Win32Exception 
      HResult=-2147467259 
      Message=The system cannot find the file specified 
      ErrorCode=-2147467259 
      NativeErrorCode=2 
      InnerException: 

我希望能夠提供關於如何整理以及爲重要背景閱讀提供建議的提示。

謝謝。

編輯:

我的連接字符串,在Web.config中,是:

<!-- local --> 
    <add name="Entities" connectionString="metadata=res://*/Models.Awesomeness.csdl|res://*/Models.Awesomeness.ssdl|res://*/Models.Awesomeness.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Awesomeness;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

回答

0

檢查您的連接字符串中的調試。

+0

我更新了我的原始帖子,以包含我的連接字符串信息。調試過程的下一步是什麼? –

1

對於我來說,在網絡配置文件中,從ConnectionString,我刪除

integrated security=True; 

和它的工作就像一個輕而易舉的!

0

點擊工具>連接到數據庫。 嘗試連接到sql服務器數據庫。 如果你不能那麼這意味着它不是連接字符串。我得到這個錯誤

"A network-related or instance-specific error occurred while establishing a connection to SQL Server." 

所以你可以搜索那個錯誤,網上有很多的幫助。

如果你能夠連接到Visual Studio中的數據庫,然後單擊數據庫上,在屬性窗口中,您將看到連接字符串。您可以將連接字符串複製並粘貼到應用程序中,然後您就會知道它是正確的。

相關問題