Blazor Web App .NET 9: Ich kann die SQLite -Datenbank im Debug -Modus öffnen und verwalten, aber nicht in der gehostetenC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Blazor Web App .NET 9: Ich kann die SQLite -Datenbank im Debug -Modus öffnen und verwalten, aber nicht in der gehosteten

Post by Anonymous »

Heute war der zweite Tag, seit ich diese Ausnahme bemerkte: < /p>

Eine Datenbankoperation ist bei der Verarbeitung der Anforderung fehlgeschlagen. SQLiteException: SQLite -Fehler 14: "Datenbankdatei nicht öffnen".
Applying existing migrations may resolve this issue There are
migrations that have not been applied to the following database(s):
BlazorWebAppAdminContext
  • 20250708123456_MyArgumentName
  • 20250709789101_MyneWargumentName1.0.0
  • 2025071011213_MyneWargumentName1.0.2
    < /ul>

    Code: Select all

    PM> Update-Database

    Alternativ können Sie anhängige Migrationen aus einer Eingabeaufforderung in Ihrem Projektverzeichnis anwenden:

    Code: Select all

    dotnet ef database update


    Hinweis: Mein .NET-Kern-Hosting-Bundle auf Windows Server ist dotnet-Hosting-9.0.6-win.exe
    Ich habe die spezifische Lösung nicht auf diese Ausgabe angewendet, auch wenn ich diese Workarounds bereits gemacht habe:
    < dass iis_iusrs Berechtigungen gelesen und geschrieben hat:
    Image
Here is my relevant source code:

Code: Select all

Program.cs
:

Code: Select all

using MyBlazorWebAppName.Components;
using Microsoft.EntityFrameworkCore;
using MyBlazorWebAppName.Data;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContextFactory(options =>
options.UseSqlite(builder.Configuration.GetConnectionString("BlazorWebAppAdminContext") ?? throw new InvalidOperationException("Connection string 'BlazorWebAppAdminContext' not found.")));

builder.Services.AddQuickGridEntityFrameworkAdapter();

builder.Services.AddDatabaseDeveloperPageExceptionFilter();

// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days.  You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
app.UseMigrationsEndPoint();
}

app.UseHttpsRedirection();

app.UseAntiforgery();

app.MapStaticAssets();
app.MapRazorComponents()
.AddInteractiveServerRenderMode();

app.Run();
< /code>
BlazorWebAppAdminContext.cs
:

Code: Select all

using Microsoft.EntityFrameworkCore;

namespace MyBlazorWebAppName.Data
{
public class BlazorWebAppAdminContext(DbContextOptions options) : DbContext(options)
{
public DbSet Admin { get; set; } = default!;
}
}
< /code>
Note: if you find this different from the default generated file's source code after following the tutorial: Build a Blazor movie database app (Overview), it's because I simply followed the code refactoring suggestions provided by the .NET framework. Nevertheless, it's still working in debug mode.
appsettings.json
:

Code: Select all

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"BlazorWebAppAdminContext": "Data Source=Data\\BlazorWebAppAdminContext-12345679-10111213-141516.db"
}
}
< /code>
Take note: for reproducible concerns, on the generated file web.config
musste ich diese Konfiguration hinzufügen, um den tatsächlichen Fehler anzuzeigen, den ich am oberen Teil dieses Frage -Threads angegeben habe:

Code: Select all



< /code>
Reference: ASP.NET Core deployment to IIS error: Development [url=viewtopic.php?t=25360]environment[/url] should not be enabled in deployed applications
Here's the full configuration of web.config
:

Code: Select all















< /code>
So, here are my questions after all these struggles in deploying my Blazor web app (.NET 9 [using Visual Studio Code]) with SQLite to IIS 8.5 on SQL Server 2012 R2 Standard:

[*]Has anybody else resolved the same issue as mine?
[*]Is this a bug or what?
[*]Do you see a misconfiguration on the project I am working with?
[*]Am I missing something here?
[/list]
EDIT: I've found out that I was using the incompatible ASP.NET Core Runtime for .NET SDK 9.0.302
Regarding the given findings, I downloaded the aspnetcore-runtime-9.0.7-win-x64.exe
und dotnet-hosting-9.0.7-win.exe und dann beide ausführbaren Dateien installiert. Quelle: Download .NET 9.0 - ASP.NET -Kernlaufzeit 9.0.7. an SQLite db file (which I found that it's relevant), which I'll quote (let's jump directly to the answer to be straightforward):

You only need to [assign] the iis_iusrs and iusr permission to the inetpub folder.

So, I Überprüfte den Ordner inetpub auf dem Windows -Server, und ich fand heraus, dass er dort noch nicht hinzugefügt wird. /> und in der Genehmigung für iis_iusrs und iusr
Ich stelle sicher, dass diese Konfigurationen:

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post