【发布时间】:2021-06-18 03:40:46
【问题描述】:
我是 dotnet 核心的新手。
我正在构建一个 Dotnet Core WebAPI 应用程序,在 Development 环境下一切正常,但是当我在 ASPNETCORE_ENVIRONMENT 中更改为 Production 时,发生了以下未处理异常:
Startup.cs
services.AddDbContext<DBContext>(options => options.UseMySql(Configuration.GetConnectionString("LocalDatabase")));
\\ Error
\\ System.ArgumentException: 'Option 'user variables' not supported.'
\\ This exception was originally thrown at this call stack:
\\ [External Code]
ReferralSystem.Startup.ConfigureServices.AnonymousMethod__0(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder) in Startup.cs
\\ [External Code]
可能的原因是什么?
【问题讨论】:
-
您是否在生产环境中使用不同的连接字符串?见github.com/mysql-net/MySqlConnector/issues/194
-
everything was working fine under Development env but when I changed to Production in ASPNETCORE_ENVIRONMENT, the following Unhandled Exception occurred请仔细检查appsettings.{Environment}.json文件和连接字符串,您可以通过此文档了解appsettings.{Environment}.json的工作原理:docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/…
标签: c# .net asp.net-mvc asp.net-core