C# Can';我再也找不到数据库了

C# Can';我再也找不到数据库了,c#,entity-framework,visual-studio-2012,C#,Entity Framework,Visual Studio 2012,我有一个带有实体框架6的ASP.NET MVC 4应用程序。我可以在Visual Studio 2013中运行此应用程序。但是web应用现在必须在服务器上(在线)。因此,我首先在IIS中添加了web应用程序 但现在我得到了这个错误: 建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。LocalDB实例API方法调用

我有一个带有实体框架6的ASP.NET MVC 4应用程序。我可以在Visual Studio 2013中运行此应用程序。但是web应用现在必须在服务器上(在线)。因此,我首先在IIS中添加了web应用程序

但现在我得到了这个错误:

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。LocalDB实例API方法调用中发生意外错误。有关错误详细信息,请参阅Windows应用程序事件日志。)

我正在使用Microsoft SQL Server 2012

我必须为数据库
SAVANTKING-PC\SQLEXPRESS
(LocalDb)\v11.0
提供服务器名称。在SQL Server 2012中,我无法访问第二个。但是我可以连接到SQL Server 2012
SAVANTKING-PC\SQLEXPRESS

因此,我附加了用于web应用程序的数据库-它最初存储在
(LocalDb)\v11.0
中。但如果我尝试在ISS中运行web应用程序,我仍然会得到相同的错误:

“/TestLCCSite”应用程序中出现服务器错误

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。LocalDB实例API方法调用中发生意外错误。有关错误详细信息,请参阅Windows应用程序事件日志。)

多谢各位

当然,我更改了连接字符串:

<connectionStrings>
    <add name="LolaBikeContext" connectionString="Data Source=SAVANTKING-PC\SQLEXPRESS;Initial Catalog=ContosoUniversity2;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

这是堆栈跟踪:

堆栈跟踪:

[SqlException (0x80131904): 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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application event log for error details.
)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6568558
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +717
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +6595000
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +219
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6597350
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6597891
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +942
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1162
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +72
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +6601145
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +103
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2102
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1079
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6605639
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278
   System.Data.SqlClient.SqlConnection.Open() +239
   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +207
   System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +438
   System.Data.Entity.Infrastructure.<>c__DisplayClass1.<Execute>b__0() +15
   System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute(Func`1 operation) +564
   System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +375
   System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +749
   System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +504
   System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +118

[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
   System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +459
   System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +51

[ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.]
   System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +300
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +83
   System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +327
   System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +118
   System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +94
   System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +248
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +618
   System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps() +23
   System.Data.Entity.Database.Exists() +40
   ContosoUniversity.Filters.SimpleMembershipInitializer..ctor() +125

[InvalidOperationException: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588]
   ContosoUniversity.Filters.SimpleMembershipInitializer..ctor() +480

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +127
   System.Activator.CreateInstance(Type type) +78
   System.Threading.LazyHelpers`1.ActivatorFactorySelector() +72
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +241
   System.Threading.LazyInitializer.EnsureInitialized(T& target, Boolean& initialized, Object& syncLock) +139
   System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +296
   System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +1137
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +112
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +132
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +1449
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +96
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +487
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +45
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +111
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +203
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +879
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +154
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +527
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +108
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +111
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +203
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +681
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12288259
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237
[SqlException(0x80131904):建立到SQL Server的连接时发生与网络相关或特定于实例的错误。找不到或无法访问该服务器。请验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:50-发生本地数据库运行时错误。LocalDB实例API方法调用中发生意外错误。有关错误详细信息,请参阅Windows应用程序事件日志。)。
)]
System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接,操作'1 wrapCloseInAction)+6568558
System.Data.SqlClient.TdsParser.throweexception和warning(TdsParserStateObject stateObj,布尔调用方连接锁,布尔异步关闭)+717
System.Data.SqlClient.TdsParser.Connect(ServerInfo ServerInfo,sqlinternalconnectionds connHandler,Boolean ignoresnopentimeout,Int64 timerExpire,Boolean encrypt,Boolean trustServerCert,Boolean integratedSecurity,Boolean with failover)+6595000
System.Data.SqlClient.SqlInternalConnectionDS.AttemptOneLogin(ServerInfo ServerInfo、String newPassword、SecureString newSecurePassword、Boolean IgnoresInOpenTimeout、TimeoutTimer timeout、Boolean withFailover)+219
System.Data.SqlClient.SqlInternalConnectionDs.LoginOfAirver(ServerInfo服务器信息、字符串新密码、SecureString NewSecureUserPassword、布尔重定向EducserInstance、SqlConnectionString连接选项、SqlCredential凭证、超时)+6597350
System.Data.SqlClient.SqlInternalConnectionDS.OpenLoginList(超时超时、SqlConnectionString连接选项、SqlCredential凭证、字符串newPassword、SecureString newSecurePassword、布尔重定向EducserInstance)+6597891
System.Data.SqlClient.SqlInternalConnectionDS..ctor(DbConnectionPoolIdentity,SqlConnectionString connectionOptions,SqlCredential凭证,对象提供信息,String newPassword,SecureString newSecurePassword,Boolean RedirectedUserConnectionInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData)+942
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项、DbConnectionPoolKey poolKey、Object poolGroupProviderInfo、DbConnectionPool池、DbConnectionOwningConnection、DbConnectionOptions用户选项)+1162
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池、DbConnectionOwningObject、DbConnectionOptions选项、DbConnectionPoolKey池键、DbConnectionOptions用户选项)+72
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection-owningObject、DbConnectionOptions-userOptions、DbConnectionInternal-oldConnection)+6601145
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject、DbConnectionOptions userOptions、DbConnectionInternal oldConnection)+103
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection-owningObject,UInt32-waitForMultipleObjectsTimeout,布尔allowCreate,布尔OnlyOnEckConnection,DbConnectionOptions-userOptions,DbConnectionInternal&connection)+2102
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject、TaskCompletionSource`1重试、DbConnectionOptions用户选项、DbConnectionInternal和connection)+116
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection所有者连接、TaskCompletionSource`1重试、DbConnectionOptions用户选项、DbConnectionInternal oldConnection、DbConnectionInternal和connection)+1079
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection、DbConnectionFactory connectionFactory、TaskCompletionSource`1 retry、DbConnectionOptions userOptions)+6605639
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1重试)+233
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重试)+278
System.Data.SqlClient.SqlConnection.Open()+239
System.Data.Entity.Infrastructure.InternalDispatcher.InternalDispatcher