首页 > 解决方案 > .NET Entity Framework 在 VS 调试中工作,但在运行时无法连接到数据库

问题描述

我有一个使用 .net Entity Framework Core 2.2 的简单 Web API。在 Visual Studio 中,一切都在调试模式下工作。但是当我构建并运行它时,它无法连接到数据库。

错误按摩:

失败:Microsoft.AspNetCore.Server.Kestrel[13]
连接 ID“0HLRCVL1R3B1L”,请求 ID“0HLRCVL1R3B1L:00000001”:应用程序引发了未处理的异常。
System.ArgumentNullException:值不能为空。
参数名称:连接字符串

在 Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
在 Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
在 TSPfizer.CentoMiner.Web.Startup.b__4_1(DbContextOptionsBuilder options ) ) 在 C:\Users\shangl02\source\repos\TSolution\CentoMinerWebAPI\Startup.cs:43 行

我错过了什么吗?

标签: c#entity-framework

解决方案


推荐阅读