2013-09-21 3 views
1

У меня мало опыта работы с C#, ASP, .NET, Visual Studio или Azure. У меня есть веб-приложение, которое выполняет штраф при развертывании на Azure (я до сих пор не понимаю, этот процесс), но при запуске Debug -> Начать отладку в 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: 

Я был бы признателен за советы о том, как их сортировать, а также предложения по существенному изучению фона.

спасибо.

EDIT:

Моя строка соединения, в 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 Server. Если вы не можете, значит, это не строка соединения. Я получил эту ошибку

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

Таким образом, вы можете найти эту ошибку, есть много помощи для нее в Интернете.

Если вы можете подключиться к базе данных в Visual Studio, щелкните по базе данных, а в окнах свойств вы увидите строку подключения. Вы можете скопировать и пропустить строку подключения в ваше приложение, тогда вы будете знать, что это правильно.

Смежные вопросы