在 launchSettings.json 中,定义了一些变量并使用这些变量进行应用程序。当我正常运行应用程序时,launchSettings.json 中可用的环境变量成功加载,并且应用程序完美运行。但是当我尝试添加迁移时,ef 工具会忽略 launchSettings.json 文件。
launchSettings.json 看起来像
{“MIN_LOG_LEVEL”:“警告”}
将 launchSettings.json 变量读取为的代码
config.AddEnvironmentVariables();
string logLevel = config["MIN_LOG_LEVEL"] // returing null
Run Code Online (Sandbox Code Playgroud)
一些代码快照
更新:我尝试使用 IIS 和 Kestrel Server,但在这两种情况下都会出现此问题。