Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调试时如何解决连接错误?_C#_Sql Server_Debugging_Asp.net Core Webapi_Visual Studio 2019 - Fatal编程技术网

C# 调试时如何解决连接错误?

C# 调试时如何解决连接错误?,c#,sql-server,debugging,asp.net-core-webapi,visual-studio-2019,C#,Sql Server,Debugging,Asp.net Core Webapi,Visual Studio 2019,我有两个项目在一个解决方案。当我尝试运行VitekAPI项目时,出现一个错误:“无法连接到web服务器‘IIS Express’” 在ConfigureServices方法内的startup类中,我添加了以下服务: services.AddDbContext<BusinessContext>(options => options.UseSqlServer(Configuration.GetConnectionString("De

我有两个项目在一个解决方案。当我尝试运行VitekAPI项目时,出现一个错误:“无法连接到web服务器‘IIS Express’”

在ConfigureServices方法内的startup类中,我添加了以下服务:

            services.AddDbContext<BusinessContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
我的数据库也已启动:

以下是指向我的存储库的链接:
尝试关闭并重新打开VS

尝试关闭并重新打开VS谢谢。这起作用了,但我不知道为什么。它即将连接到IIS Express和相关服务,而不是DB连接,主要是为了获得windows权限。
 "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=BusinessContext-bc;Trusted_Connection=True;MultipleActiveResultSets=true"