{"record":{"id":"9ed9dd94b43752e1","repo":"nopSolutions/nopCommerce","slug":"databasecreationerror","errorCode":null,"errorMessage":"DatabaseCreationError","messagePattern":"DatabaseCreationError","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/Presentation/Nop.Web/Controllers/InstallController.cs","lineNumber":236,"sourceCode":"\r\n            DataSettingsManager.SaveSettings(new DataConfig\r\n            {\r\n                DataProvider = model.DataProvider,\r\n                ConnectionString = connectionString,\r\n                Collation = model.Collation,\r\n                CharacterSet = model.CharacterSet\r\n            }, _fileProvider);\r\n\r\n            if (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())\r\n            {\r\n                try\r\n                {\r\n                    SetProgressMessage(_locService.Value.GetResource(\"Progress.CreateDatabase\"));\r\n                    dataProvider.CreateDatabase();\r\n                }\r\n                catch (Exception ex)\r\n                {\r\n                    throw new Exception(string.Format(_locService.Value.GetResource(\"DatabaseCreationError\"), ex.Message));\r\n                }\r\n            }\r\n            else\r\n            {\r\n                //check whether database exists\r\n                if (!await dataProvider.DatabaseExistsAsync())\r\n                    throw new Exception(_locService.Value.GetResource(\"DatabaseNotExists\"));\r\n            }\r\n\r\n            SetProgressMessage(_locService.Value.GetResource(\"Progress.InitializeDatabase\"));\r\n            dataProvider.InitializeDatabase();\r\n\r\n            var cultureInfo = new CultureInfo(NopCommonDefaults.DefaultLanguageCulture);\r\n            var regionInfo = new RegionInfo(NopCommonDefaults.DefaultLanguageCulture);\r\n\r\n            var languagePackInfo = (DownloadUrl: string.Empty, Progress: 0);\r\n            if (model.InstallRegionalResources)\r\n            {\r","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Controllers/InstallController.cs#L218-L254","documentation":"Thrown during installation when database creation fails. The installer attempts dataProvider.CreateDatabase() (only when model.CreateDatabaseIfNotExists is true and the DB does not exist) and wraps the inner exception's message into the localized 'DatabaseCreationError' template.","triggerScenarios":"InstallController line ~236: CreateDatabase() throws — the DB server is unreachable, credentials lack CREATE DATABASE permission, a DB of that name already exists, or the provider raised a provider-specific error.","commonSituations":"SQL/MySQL account has no DDL privileges; the DB server hostname/port is wrong or firewalled; the target name collides with an existing DB; SQL Server 'contained database' or file-path permissions block creation; MySQL maximum DB count reached.","solutions":["Inspect the wrapped inner exception message in the thrown error to get the provider-specific cause, then address it (permissions, connectivity, naming).","Grant the installing account CREATE DATABASE / DB owner privileges, or pre-create the empty DB and untick 'Create database if not exists'.","Verify server connectivity (host, port, firewall, SQL Browser) and that the account can log in."],"exampleFix":"// before\ncatch (Exception ex)\n{\n    throw new Exception(string.Format(_locService.Value.GetResource(\"DatabaseCreationError\"), ex.Message));\n}\n\n// troubleshooting: read ex.Message — common fixes:\n// 1) GRANT CREATE DATABASE, or add the user to dbcreator server role.\n// 2) Pre-create the DB in SSMS/phpMyAdmin and uncheck 'Create database if not exists'.\n// 3) Confirm the server is reachable: telnet <host> <port>.","handlingStrategy":"try-catch","validationCode":"// Pre-flight: can the account reach the server and create DBs?\nif (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())\n{\n    // surface a clear error if the server is unreachable rather than letting CreateDatabase throw\n}","typeGuard":null,"tryCatchPattern":"catch (Exception ex)\n{\n    var inner = ex.InnerException?.Message ?? ex.Message;\n    _logger.Error($\"Database creation failed: {inner}\");\n    ModelState.AddModelError(\"\", string.Format(_locService.Value.GetResource(\"DatabaseCreationError\"), inner));\n}","preventionTips":["Grant the install account dbcreator/CREATE DATABASE privileges, or pre-create the empty DB.","Confirm server connectivity and firewall rules before running the installer.","Read the wrapped inner exception for the true provider-specific cause."],"tags":["nopcommerce","install","database","permissions","provisioning"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}