当前位置:  开发笔记 > 编程语言 > 正文

指定的LocalDB实例不存在

如何解决《指定的LocalDB实例不存在》经验,为你挑选了0个好方法。

我正在尝试使用EntityFramework 6在SQL Server 2015 Express中构建ASP.NET MVC 5 Web应用程序但是当我调试应用程序并转到需要数据库的页面时,我收到以下错误.

System.Data.SqlClient.SqlException未被用户代码处理ErrorCode = -2146232060 HResult = -2146232060 LineNumber = 0 Message = Error relacionado con la redoespecíficodela instancia mientras se>establecíaunaconexiónconel servidor SQL Server.没有服务条件>没有建立可接受的服务.Compruebe que el nombre de la instancia es correcto> y que SQLServerestáconfiguradopara admitir conexiones remotas.(提供者:> SQL网络接口,错误:50 - Se produjo un error de本地数据库>运行时.La instancia de LocalDB especificada no existe.)

这个错误提到有一个远程连接问题,但这是不可能的,因为我在本地.然后我收到以下错误:发生localDB实例本地数据库运行时错误.指定的LocalDB实例不存在.

堆栈跟踪:

    en System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
       en System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       en System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       en System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       en System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       en System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       en System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       en System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       en System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       en System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       en System.Data.SqlClient.SqlConnection.Open()
       en System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection t, DbConnectionInterceptionContext c)
       en System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
       en System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
       en System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass33.b__32()
       en System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.b__0()
       en System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
       en System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
       en System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act)
       en System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
       en System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript)
       en System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
       en System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
       en System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()
       en System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection)
       en System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
       en System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
       en System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext)
       en System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState)
       en System.Data.Entity.Database.Create(DatabaseExistenceState existenceState)
       en System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
       en System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.b__e()
       en System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
       en System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
       en System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c)
       en System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
       en System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
       en System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
       en System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       en System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       en System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
       en System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
       en System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       en System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       en WebApplication10.Controllers.AlbumsController.Index() en C:\Users\Develop2\Documents\Visual Studio 2015\Projects\WebApplication10\WebApplication10\Controllers\AlbumsController.cs:línea 20
       en lambda_method(Closure , ControllerBase , Object[] )
       en System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       en System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       en System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       en System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       en System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       en System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3d()
       en System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.b__3f()

编辑
我的连接字符串看起来像:

 
    
    
  

编辑2


    
    
        
    
     
    
      
    
  

应该是什么问题?

正如Cigano Morrison建议的那样,问题是localDB的实例丢失了所以我不得不在命令行中运行以下命令 sqllocaldb c MSSQLLocalDB 11.0

推荐阅读
手机用户2402852307
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有