尝试创建数据库时出错:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误

萨迪许

我正在尝试在 ASP.NET 中编写应用程序,已经创建了模型、上下文并希望使用 EF Code-First 方法创建数据库,但它不起作用。

此外,文件夹App_Data是空的。我已经安装了 SQL Server 2017 Express。

我尝试了我能找到的所有可能的解决方案,但仍然没有任何效果。

连接字符串:

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-BM-20171207072135.mdf;Initial Catalog=aspnet-BM-20171207072135;Integrated Security=True" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

但是,我收到此错误:

PM> update-database 

> Specify the '-Verbose' flag to view the SQL
> statements being applied to the target database

System.Data.SqlClient.SqlException (0x80131904):建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供程序:SQL 网络接口,错误:
发生50本地数据库运行时错误。LocalDB 实例启动期间发生错误:SQL Server 进程无法启动。

错误:
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool System and String AccessToken at .Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningKey, PoolConnectionOptions)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.DataProvider DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSourceDbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, One Boolean allowCheckConnections, userOptions only, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)连接)在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSourceDbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, One Boolean allowCheckConnections, userOptions only, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)连接)在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSourceBoolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSourceBoolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1重试,DbConnectionOptions USEROPTIONS,DbConnectionInternal oldConnection,DbConnectionInternal&连接)在System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(的DbConnection outerConnection,DbConnectionFactory connectionFactory的,TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1重试,DbConnectionOptions USEROPTIONS)在System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1重试) 在 System.Data.SqlClient.SqlConnection.Open() 在 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection t, DbConnectionInterceptionContext c) 在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action2 操作,TInterceptionContext拦截上下文,动作3 executing, Action3 在 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection 连接,DbInterceptionContext 拦截上下文) 在 System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass33.b__32() 在 System.Data.Entity.SqlServer 上执行) .DefaultSqlExecutionStrategy.<>c__DisplayClass1.b__0() 在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func 1 operation) at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action1 act) 在 System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action 1 act) at System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) 在 System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() at System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) at System.Data.Entity.Migrations.DbMigrator .EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) .MigratorBase.Update(String targetMigration) 在 System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore() 在 System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() ClientConnectionId:00000000-0000- 0000-0000-000000000000

>

错误编号:-1983577846,状态:0,类别:20
与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供程序:SQL 网络接口,错误:50 - 发生本地数据库运行时错误。LocalDB 实例启动期间发生错误:SQL Server 进程无法启动)

皮特

确保您的 sql 服务器已启动并正在运行。从 windows 服务 (services.msc) 看。或者为了确保,首先尝试使用 VS DB 连接或 SSMS 手动连接。

尝试从您的 sql 服务属性中检查这个(下面)。 在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

建立与SQL Server的连接时发生网络相关或特定于实例的错误

来自分类Dev

MySQL“与SQL Server建立连接时发生与网络相关或特定于实例的错误”

来自分类Dev

建立与SQL Server的连接时发生与网络相关或特定于实例的错误(在Asp.net Mvc应用程序中)

来自分类Dev

实体框架数据库问题-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

来自分类Dev

Sqlcmd:错误:Microsoft SQL Server本机客户端10.0:发生与网络相关或特定于实例的错误

来自分类Dev

从SQL Server数据库读取数据时出错

来自分类Dev

无法建立与SQL Server数据库的连接

来自分类Dev

使用Sequelize连接到SQL Server数据库时出错

来自分类Dev

尝试删除SQL Server数据库时出现错误21

来自分类Dev

在stimulsoft报告上建立到sql服务器错误26的连接时发生与网络相关或特定于实例的错误

来自分类Dev

尝试插入SQL Server数据库时'PK'错误附近的语法不正确

来自分类Dev

如何建立与远程数据库sql server的连接?

来自分类Dev

尝试连接到SQL Server数据库时出错

来自分类Dev

尝试连接到SQL Server数据库时出错

来自分类Dev

尝试连接到SQL Server数据库时出错

来自分类Dev

尝试连接到SQL Server数据库时出错

来自分类Dev

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。查找指定的服务器/实例时出错)

来自分类Dev

建立与SQL Server的连接时发生网络相关错误或特定于实例的错误

来自分类Dev

尝试将数据插入SQL Server数据库时打开连接的麻烦

来自分类Dev

尝试连接到SQL Server数据库时出现“ SqlException未处理”错误

来自分类Dev

建立与SQL Server的连接时出错

来自分类Dev

建立与SQL Server的连接时发生与网络相关或特定于实例的错误(在Asp.net Mvc应用程序中)

来自分类Dev

实体框架数据库问题-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

来自分类Dev

尝试删除SQL Server数据库时出现错误21

来自分类Dev

将数据库 mdb 导入 Sql Server 时出错

来自分类Dev

尝试连接到 MySQL 服务器:建立到 SQL Server 的连接时发生与网络相关或特定于实例的错误

来自分类Dev

PHP sqlsrv_connect to SQL Server:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误

来自分类Dev

Kubernetes 与 SQL Server 建立连接时发生与网络相关或特定于实例的错误

来自分类Dev

在数据库 SQL Server 2016 中添加数据时出错

Related 相关文章

  1. 1

    建立与SQL Server的连接时发生网络相关或特定于实例的错误

  2. 2

    MySQL“与SQL Server建立连接时发生与网络相关或特定于实例的错误”

  3. 3

    建立与SQL Server的连接时发生与网络相关或特定于实例的错误(在Asp.net Mvc应用程序中)

  4. 4

    实体框架数据库问题-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

  5. 5

    Sqlcmd:错误:Microsoft SQL Server本机客户端10.0:发生与网络相关或特定于实例的错误

  6. 6

    从SQL Server数据库读取数据时出错

  7. 7

    无法建立与SQL Server数据库的连接

  8. 8

    使用Sequelize连接到SQL Server数据库时出错

  9. 9

    尝试删除SQL Server数据库时出现错误21

  10. 10

    在stimulsoft报告上建立到sql服务器错误26的连接时发生与网络相关或特定于实例的错误

  11. 11

    尝试插入SQL Server数据库时'PK'错误附近的语法不正确

  12. 12

    如何建立与远程数据库sql server的连接?

  13. 13

    尝试连接到SQL Server数据库时出错

  14. 14

    尝试连接到SQL Server数据库时出错

  15. 15

    尝试连接到SQL Server数据库时出错

  16. 16

    尝试连接到SQL Server数据库时出错

  17. 17

    建立与SQL Server的连接时发生与网络相关或特定于实例的错误。查找指定的服务器/实例时出错)

  18. 18

    建立与SQL Server的连接时发生网络相关错误或特定于实例的错误

  19. 19

    尝试将数据插入SQL Server数据库时打开连接的麻烦

  20. 20

    尝试连接到SQL Server数据库时出现“ SqlException未处理”错误

  21. 21

    建立与SQL Server的连接时出错

  22. 22

    建立与SQL Server的连接时发生与网络相关或特定于实例的错误(在Asp.net Mvc应用程序中)

  23. 23

    实体框架数据库问题-建立与SQL Server的连接时发生与网络相关或特定于实例的错误

  24. 24

    尝试删除SQL Server数据库时出现错误21

  25. 25

    将数据库 mdb 导入 Sql Server 时出错

  26. 26

    尝试连接到 MySQL 服务器:建立到 SQL Server 的连接时发生与网络相关或特定于实例的错误

  27. 27

    PHP sqlsrv_connect to SQL Server:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误

  28. 28

    Kubernetes 与 SQL Server 建立连接时发生与网络相关或特定于实例的错误

  29. 29

    在数据库 SQL Server 2016 中添加数据时出错

热门标签

归档