繁体   English   中英

ASP.NET Core 5 Web API with Entity Framework works when running in IDE but not when published to folder and installed in IIS

[英]ASP.NET Core 5 Web API with Entity Framework works when running in IDE but not when published to folder and installed in IIS

我有这样一个令人沮丧的问题。 我已经使用 Entity Framework Core 编写了 ASP.NET Core 5 Web API。 这在我的开发机器上完美运行,如果我将项目复制到另一台机器,我可以简单地更新连接字符串,它也可以在那里运行。

每当我发布项目并尝试通过 IIS 访问它时。 我收到以下错误。

类别:Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer
事件编号:2
跨度 ID:f97ede8e15417a59
TraceId:7ebb4da21f77111ec887913667671c80
父 ID:0000000000000000
请求ID:80000017-0002-fe00-b63f-84710c7967bb
请求路径:/api/v1/users/auth

连接 ID “18302628895834243094”,请求 ID “80000017-0002-fe00-b63f-84710c7967bb”:应用程序引发了未处理的异常。

例外:
System.PlatformNotSupportedException:Strings.PlatformNotSupported_DataSqlClient

在 Microsoft.Data.SqlClient.SqlConnectionStringBuilder..ctor(字符串连接字符串)
在 Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.<>c.<get_IsMultipleActiveResultSetsEnabled>b__7_0(String cs)
在 System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd(TKey key, Func 2 valueFactory)
在 Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.get_IsMultipleActiveResultSetsEnabled()

This is my first time publishing a .net core app to IIS but I have followed a lot of guidance from the community and my swagger home page loads so this is definitely about SQL.

以下是我的发布资料。 无法弄清楚我做错了什么。

谢谢您的帮助。

在此处输入图像描述

我设法解决了我自己的问题。 它实际上已被清楚地记录在案。 我需要将以下内容添加到我的 program.cs 中。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM