Entity framework core 具有实体框架的Blazor Wasm应用程序可以在桌面上运行,但不能作为Azure静态网站运行

Entity framework core 具有实体框架的Blazor Wasm应用程序可以在桌面上运行,但不能作为Azure静态网站运行,entity-framework-core,blazor-webassembly,Entity Framework Core,Blazor Webassembly,当客户端通过服务器控制器(而不是桌面)执行任何数据库操作时,部署版本中会出现问题: 我收到500服务器错误。问题似乎是SQL Server数据库访问问题。 我在桌面上(使用IIS Express)和部署时都在使用Azure Sql Server。相同的连接字符串 我在这里看过类似的问题和解决方案,但没有找到一个有效的 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

当客户端通过服务器控制器(而不是桌面)执行任何数据库操作时,部署版本中会出现问题:

我收到500服务器错误。问题似乎是SQL Server数据库访问问题。 我在桌面上(使用IIS Express)和部署时都在使用Azure Sql Server。相同的连接字符串

我在这里看过类似的问题和解决方案,但没有找到一个有效的

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: net_http_message_not_success_statuscode, 500, Internal Server Error
System.Net.Http.HttpRequestException: net_http_message_not_success_statuscode, 500, Internal Server Error
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at System.Net.Http.Json.HttpClientJsonExtensions.<GetFromJsonAsyncCore>d__9`1[[EFBlazorBasics_Wasm.Shared.Activity[], EFBlazorBasics_Wasm.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at EFBlazorBasics_Wasm.Client.Pages.FetchDbDataDirect.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
加载资源失败:服务器响应状态为500(内部服务器错误)
blazor.webassembly.js:1 crit:Microsoft.AspNetCore.Components.webassembly.Rendering.WebAssemblyRenderer[100]
未处理的异常呈现组件:网络\u http\u消息\u未\u成功\u状态码,500,内部服务器错误
System.Net.Http.HttpRequestException:Net\u Http\u消息\u未\u成功\u状态码,500,内部服务器错误
在System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()中
在System.Net.Http.Json.HttpClientJsonExtensions.d_u9`1[[EFBlazorBasics_Wasm.Shared.Activity[],EFBlazorBasics_Wasm.Shared,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null]]上。MoveNext()
在EFBlazorBasics_Wasm.Client.Pages.FetchDbDataDirect.OnInitializedAsync()中
在Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()中
位于Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

结果表明,在为部署配置应用程序时,我已在Visual Studio的发布面板上将其配置为使用同一Azure SQL Server上的另一个数据库,从而覆盖了连接字符串的appsettings.json设置


我应该注意到左边的服务依赖项下使用了什么db。相反,我在ConfigureServices()中的Startup类中将连接字符串记录为静态字符串,并将其作为“确定显示”的内容传递回客户端。

应用程序如何获得访问Azure Sql数据库的授权?是用户名/密码、RBAC、托管标识吗?服务器中appsettings.json连接字符串中的SQL DB用户名和密码。捕捉得好!这是有用的信息,因为如果您不知道在哪里查找,发布设置可能会“隐藏”某些内容。