簡體   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