简体   繁体   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

I have such a frustrating issue.我有这样一个令人沮丧的问题。 I have authored an ASP.NET Core 5 Web API with Entity Framework Core.我已经使用 Entity Framework Core 编写了 ASP.NET Core 5 Web API。 This runs perfectly on my dev machine and if I copy my project to another machine I can simply update the connection string and it runs there as well.这在我的开发机器上完美运行,如果我将项目复制到另一台机器,我可以简单地更新连接字符串,它也可以在那里运行。

Whenever I publish the project and attempt to access it via IIS.每当我发布项目并尝试通过 IIS 访问它时。 I get the following error.我收到以下错误。

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

Connection ID "18302628895834243094", Request ID "80000017-0002-fe00-b63f-84710c7967bb": An unhandled exception was thrown by the application.连接 ID “18302628895834243094”,请求 ID “80000017-0002-fe00-b63f-84710c7967bb”:应用程序引发了未处理的异常。

Exception:例外:
System.PlatformNotSupportedException: Strings.PlatformNotSupported_DataSqlClient System.PlatformNotSupportedException:Strings.PlatformNotSupported_DataSqlClient

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

Below is my publishing profile.以下是我的发布资料。 Can't figure out what I am doing wrong.无法弄清楚我做错了什么。

Thanks for the help.谢谢您的帮助。

在此处输入图像描述

I managed to resolve my own issue.我设法解决了我自己的问题。 It was actually clearly documented.它实际上已被清楚地记录在案。 I needed to add the following to my program.cs.我需要将以下内容添加到我的 program.cs 中。

在此处输入图像描述

暂无
暂无

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

相关问题 ASP.Net Core Web API 适用于 IIS Express,但在部署到 IIS 时不起作用 - ASP.Net Core Web API works on IIS Express, but not working when deployed to IIS 发布到IIS 7.5时ASP.NET Core 404错误 - ASP.NET Core 404 Error When Published to IIS 7.5 ASP.NET 核心 Web API 使用实体框架核心 - ASP.NET Core Web API using Entity Framework Core 使用 ASP.NET Core 2.2 Web API 项目中的实体框架类库时抛出异常 - Exception thrown when using Entity Framework class library from ASP.NET Core 2.2 Web API project 自托管 ASP.NET Web API 时未找到 404,在 IIS 中工作正常 - 404 not found when self hosting ASP.NET Web API, works fine within IIS 仅当在 IIS 中发布时,在 ASP.net Core 3.1 WebAPI 中启用 CORS 时出错 - Error on Enable CORS in ASP.net Core 3.1 WebAPI in only when published in IIS 尽管安装了 AspNetCoreModule,但在 IIS 中运行 ASP.NET Core 应用程序时出现错误 500.19 和 0x8007000d - Error 500.19 with 0x8007000d when running ASP.NET Core app in IIS despite AspNetCoreModule being installed 当我在 IIS 上发布 asp net core 5 项目时出现错误 - when I published asp net core 5 project on IIS it has an error ASP.NET Web API 在 IIS 中发布时不起作用? - ASP.NET Web API does not work when publish it in IIS? 将“react js”构建到我的“asp.net core web api”的 wwwroot 文件夹时出现路由问题 - Routing problem when building "react js" to wwwroot folder of my "asp.net core web api"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM