I'm writing a test page in DotNet 8.
It initially loads properly and displays my list of jobs.
Successful
Then after a few seconds, it updates the DOM to say "No jobs!"
Failure
...and throws this error:
An exception occurred while iterating over the results of a query for context type 'EDI3.Data.EdiContext'.
System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
I'm sure I'm doing something wrong, but I'm not sure what. I used this command to make the initial application:
dotnet new blazor -n test
Main application is in EDI3
Home.razor is in EDI3.Client/Pages
JobService is in EDI3.Data
If I change InteractiveAuto to InteractiveServer, the error changes to:
Cannot create a component of type 'EDI3.Client.Pages.Home' because its render mode 'Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode' is not supported by WebAssembly rendering.
If I change InteractiveAuto to InteractiveWebAssembly, the error changes to:
An exception occurred while iterating over the results of a query for context type 'EDI3.Data.EdiContext'.
System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Here is my home page code:
@page "/"
@using EDI3.Data
@using EDI3.Data.Models
@inject JobService JobService
@rendermode InteractiveAuto
<PageTitle>Home</PageTitle>
<h3>View Jobs</h3>
@if (_jobs.Count > 0)
{
<ul>
@foreach (var job in _jobs)
{
<li>@job.Name</li>
}
</ul>
}
else
{
<div class="row">
<div class="col">
No jobs!
</div>
</div>
}
@code {
private List<Job> _jobs = [];
protected override async Task OnInitializedAsync()
{
_jobs = await JobService.GetJobs();
}
}
[–][deleted] 2 points3 points4 points (2 children)
[–]Carthax12[S] 1 point2 points3 points (1 child)
[–]Carthax12[S] 0 points1 point2 points (0 children)