c# - .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 行
我错过了什么吗?
解决方案
推荐阅读
- javascript - 为什么嵌套路由在 ReactJs 中不起作用?我使用的是 react-router 5.2 版
- c# - C# Assembly.Load() 方法加载了错误的 dll?
- php - 使用 Laravel 同时插入两个表的主键和外键
- vim - 寻找 。-type f -name "*.sw[klmnop]" -delete 在 Windows 中?
- javascript - Sqs 没有发送消息也没有错误显示
- spring-boot - 强制 Tomcat 响应 BadRequest 错误的 JSON 响应:在请求目标中发现无效字符
- reactjs - 如何在反应中从 URL 获取 exif 数据?
- angular - 使用 JS 或 PNG 作为 IIS 路由中的子字符串的角度路由
- html - 带有显示内联块的跨度,嵌套在锚标记中,没有下划线
- android - 如何解决 Android TV 模拟器 DNS 查找错误?(java.net.UnknownHostException:无法解析主机)