{"record":{"id":"f23aded1dc90d23c","repo":"nopSolutions/nopCommerce","slug":"no-default-store-could-be-loaded","errorCode":null,"errorMessage":"No default store could be loaded","messagePattern":"No default store could be loaded","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/Libraries/Nop.Services/Installation/InstallRequiredData.cs","lineNumber":2253,"sourceCode":"        var crVendors = new CustomerRole\n        {\n            Name = \"Vendors\",\n            Active = true,\n            IsSystemRole = true,\n            SystemName = NopCustomerDefaults.VendorsRoleName\n        };\n        var customerRoles = new List<CustomerRole>\n            {\n                crAdministrators,\n                crRegistered,\n                crGuests,\n                crVendors\n            };\n\n        await _dataProvider.BulkInsertEntitiesAsync(customerRoles);\n\n        //default store \n        var defaultStore = await Table<Store>().FirstOrDefaultAsync() ?? throw new Exception(\"No default store could be loaded\");\n\n        var storeId = defaultStore.Id;\n\n        //admin user\n        var adminUser = new Customer\n        {\n            CustomerGuid = Guid.NewGuid(),\n            Email = _installationSettings.AdminEmail,\n            Username = _installationSettings.AdminEmail,\n            Active = true,\n            CreatedOnUtc = DateTime.UtcNow,\n            LastActivityDateUtc = DateTime.UtcNow,\n            RegisteredInStoreId = storeId\n        };\n\n        var defaultAdminUserAddress = await _dataProvider.InsertEntityAsync(\n            new Address\n            {","sourceCodeStart":2235,"sourceCodeEnd":2271,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Installation/InstallRequiredData.cs#L2235-L2271","documentation":"Thrown by the installer when seeding default store-scoped entities (admin user, etc.). It loads the first Store record to obtain storeId for cross-references. If no Store row exists, there is no default store context and installation cannot continue. This means the store-seeding step (which creates the default Store) either did not run or failed.","triggerScenarios":"Running installation before the default Store is inserted; a custom install order that delays Store seeding; a migration that removed all Store rows.","commonSituations":"Partial reinstall against a half-cleaned database; test database where Stores were truncated; installer interrupted mid-run leaving inconsistent state.","solutions":["Run the installer in its default order so the default Store is inserted first.","Reset the database to a clean state and reinstall.","Verify the Stores table contains the default store row before invoking this installer step.","Ensure no migration or script deleted the default Store out from under the installer."],"exampleFix":"// before\nvar defaultStore = await Table<Store>().FirstOrDefaultAsync()\n    ?? throw new Exception(\"No default store could be loaded\");\n\n// after - guard with actionable message\nvar defaultStore = await Table<Store>().FirstOrDefaultAsync()\n    ?? throw new InvalidOperationException(\"Default Store not seeded; run the store installation step first.\");","handlingStrategy":"validation","validationCode":"// Confirm a default store exists before referencing storeId\nif (!await Table<Store>().AnyAsync())\n    throw new InvalidOperationException(\"Default Store not seeded; run store installation first.\");","typeGuard":"static async Task<bool> HasDefaultStoreAsync(IRepository<Store> repo)\n    => await repo.Table.AnyAsync();","tryCatchPattern":"try { await InstallStoreScopedEntitiesAsync(); }\ncatch (Exception ex) when (ex.Message == \"No default store could be loaded\")\n{ /* seed the default Store, then retry */ }","preventionTips":["Run store seeding before any store-scoped entity installation.","Never truncate Stores between install steps.","Start installs from a clean database."],"tags":["installation","store","seeding","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}