Skip to content

Fix installing on LiteDB - #997

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/litedb-install
Oct 29, 2026
Merged

KrzysztofPajak merged 1 commit into
developfrom
fix/litedb-install

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Issue

A new installation on LiteDB fails with "Setup failed: The process cannot access the file '...\App_Data\database.db' because it is being used by another process."

InstallationService.CreateTables asks IDatabaseFactoryContext for a database context before it checks the provider. For LiteDB that opens a second LiteDatabase on App_Data/database.db, which the LiteDatabase registered in DI already holds open, and LiteDB refuses the second handle. The context is only used for MongoDB (LiteDB has no tables or indexes to create there), so the failing open is also unnecessary.

To reproduce on develop: set Database:UseLiteDb to true in App_Data/appsettings.json, start the app, choose LiteDB in the installer and install.

Solution

Create the database context only inside the MongoDB branch of CreateTables. The MongoDB path is unchanged.

Breaking changes

None.

Testing

  1. Set "UseLiteDb": true in src/Web/Grand.Web/App_Data/appsettings.json, delete App_Data/Settings.cfg and App_Data/database.db if present.
  2. Start Grand.Web, open /install, choose LiteDB, tick sample data and install. Before the fix this fails with the message above; with the fix it completes.
  3. Restart the app: the storefront and the admin panel work (product page, /Admin/Product/List with the sample products).
  4. Install on MongoDB as usual: unchanged.

CreateTables opened a database context before checking the provider. For
LiteDB that is a second LiteDatabase on the file the one registered in DI
already holds, so the installation failed with "being used by another
process". The context is only needed for MongoDB and is now created there.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@KrzysztofPajak
KrzysztofPajak merged commit b136c22 into develop Oct 29, 2026
8 of 9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/litedb-install branch October 29, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants