Skip to content
Learn Netverks
1

WinUI 3 MSIX app from Microsoft Store fails to create SQLite tables, but works in Debug/local build

asked 8 hours ago by @qa-i2qegshts8f77p0gjaxg 0 rep · 40 views

sqlite entity framework core .net 8.0 winui 3 msix

I have a WinUI 3 / .NET 8 app packaged as MSIX and published through Microsoft Store.

The app uses EF Core 8 with SQLite. On startup I initialize the database with migrations:

using var db = Services
    .GetRequiredService<IDbContextFactory<AppDbContext>>()
    .CreateDbContext();

DatabaseMigrationService.Migrate(db);

The app works correctly when I run it locally from Visual Studio / Debug. However, after installing the Microsoft Store version, some pages stay empty or fail to load data. In version 1.1.0.0, the task pages were stuck on a loading spinner. After adding try/finally around loading logic, the spinner disappears, but the database still appears to be missing tables and adding new tasks fails.

The app writes errors to errors.log. From the store-installed version I get:

[2026-05-31 16:38:35] Unhandled: SQLite Error 1: 'no such table: pomodoro_table'.
[2026-05-31 16:38:35] Unhandled: SQLite Error 1: 'no such table: pomodoro_table'.
[2026-05-31 16:38:35] Unhandled: SQLite Error 1: 'no such table: task_table'.

After a later store update:

[2026-05-31 23:53:46] Unhandled: SQLite Error 1: 'no such table: pomodoro_table'.
[2026-05-31 23:53:46] Unhandled: SQLite Error 1: 'no such table: pomodoro_table'.
[2026-05-31 23:53:49] Unhandled: An error occurred while saving the entity changes. See the inner exception for details.

My project file had trimming enabled for non-debug builds:

<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>

I suspect the Microsoft Store / Release MSIX build behaves differently because PublishTrimmed=True, and EF Core migrations may not be fully trimming-safe.

Relevant migration startup code before the latest attempted fix:

public static void Migrate(AppDbContext db)
{
    var connection = db.Database.GetDbConnection();
    db.Database.OpenConnection();

    try
    {
        if (TableExists(connection, "task_table"))
        {
            EnsureHistoryTable(connection);
            EnsureLegacySchema(connection);
            EnsureBaselineHistory(connection);

            if (ColumnExists(connection, "pomodoro_table", "pomodoro_review"))
                EnsureMigrationHistory(connection, PomodoroReviewMigrationId);
        }

        db.Database.Migrate();
    }
    finally
    {
        db.Database.CloseConnection();
    }
}

The issue is that after installing from the store, it looks like db.Database.Migrate() either fails or completes without creating the expected tables. The app then continues running and later queries fail with no such table.

Questions

  1. Can PublishTrimmed=True break EF Core SQLite migrations in a WinUI 3 MSIX app?

  2. Should EF Core trimming be disabled for store/release builds?

  3. Is there a recommended way to initialize or repair an EF Core SQLite database in a packaged WinUI 3 app?

  4. Should I use Database.Migrate(), EnsureCreated(), or a manual schema fallback for this kind of packaged app?

I am considering changing the project to:

<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">False</PublishTrimmed>

and adding a post-migration schema validation/fallback that creates missing tables if Migrate() does not.

Is this the correct approach, or is there a better store-safe way to handle EF Core SQLite migrations in WinUI 3?

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

0 answers

Your answer