nopSolutions/nopCommerce · critical · Exception

DatabaseCreationError

Error message

DatabaseCreationError

What it means

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.

Source

Thrown at src/Presentation/Nop.Web/Controllers/InstallController.cs:236

            DataSettingsManager.SaveSettings(new DataConfig
            {
                DataProvider = model.DataProvider,
                ConnectionString = connectionString,
                Collation = model.Collation,
                CharacterSet = model.CharacterSet
            }, _fileProvider);

            if (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())
            {
                try
                {
                    SetProgressMessage(_locService.Value.GetResource("Progress.CreateDatabase"));
                    dataProvider.CreateDatabase();
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format(_locService.Value.GetResource("DatabaseCreationError"), ex.Message));
                }
            }
            else
            {
                //check whether database exists
                if (!await dataProvider.DatabaseExistsAsync())
                    throw new Exception(_locService.Value.GetResource("DatabaseNotExists"));
            }

            SetProgressMessage(_locService.Value.GetResource("Progress.InitializeDatabase"));
            dataProvider.InitializeDatabase();

            var cultureInfo = new CultureInfo(NopCommonDefaults.DefaultLanguageCulture);
            var regionInfo = new RegionInfo(NopCommonDefaults.DefaultLanguageCulture);

            var languagePackInfo = (DownloadUrl: string.Empty, Progress: 0);
            if (model.InstallRegionalResources)
            {

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Inspect the wrapped inner exception message in the thrown error to get the provider-specific cause, then address it (permissions, connectivity, naming).
  2. Grant the installing account CREATE DATABASE / DB owner privileges, or pre-create the empty DB and untick 'Create database if not exists'.
  3. Verify server connectivity (host, port, firewall, SQL Browser) and that the account can log in.

Example fix

// before
catch (Exception ex)
{
    throw new Exception(string.Format(_locService.Value.GetResource("DatabaseCreationError"), ex.Message));
}

// troubleshooting: read ex.Message — common fixes:
// 1) GRANT CREATE DATABASE, or add the user to dbcreator server role.
// 2) Pre-create the DB in SSMS/phpMyAdmin and uncheck 'Create database if not exists'.
// 3) Confirm the server is reachable: telnet <host> <port>.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: can the account reach the server and create DBs?
if (model.CreateDatabaseIfNotExists && !await dataProvider.DatabaseExistsAsync())
{
    // surface a clear error if the server is unreachable rather than letting CreateDatabase throw
}

Try / catch

catch (Exception ex)
{
    var inner = ex.InnerException?.Message ?? ex.Message;
    _logger.Error($"Database creation failed: {inner}");
    ModelState.AddModelError("", string.Format(_locService.Value.GetResource("DatabaseCreationError"), inner));
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/9ed9dd94b43752e1. Report an issue: GitHub.