{"id":"f71b431e0c424d5f","repo":"sequelize/sequelize","slug":"the-dialect-option-must-be-a-dialect-class-pass","errorCode":null,"errorMessage":"The \"dialect\" option must be a dialect class. Pass the class exported by your dialect package instead.","messagePattern":"The \"dialect\" option must be a dialect class\\. Pass the class exported by your dialect package instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/sequelize-typescript.ts","lineNumber":489,"sourceCode":"\n    if ('dialectModule' in options) {\n      throw new Error(\n        'The \"dialectModule\" option has been replaced with an equivalent option specific to your dialect. Please refer to the documentation of your dialect at https://sequelize.org to learn about the alternative.',\n      );\n    }\n\n    if ('typeValidation' in options) {\n      throw new Error(\n        'The typeValidation has been renamed to noTypeValidation, and is false by default',\n      );\n    }\n\n    if (!options.dialect) {\n      throw new Error('The \"dialect\" option must be explicitly supplied since Sequelize 4');\n    }\n\n    if (typeof options.dialect !== 'function') {\n      throw new Error(\n        'The \"dialect\" option must be a dialect class. Pass the class exported by your dialect package instead.',\n      );\n    }\n\n    // Synchronize ModelDefinition map with the registered models set\n    listenForModelDefinition(model => {\n      const modelName = model.modelDefinition.modelName;\n\n      // @ts-expect-error -- remove this disable once all sequelize.js has been migrated to TS\n      if (model.sequelize === (this as Sequelize)) {\n        const existingModel = this.models.get(modelName);\n        if (existingModel) {\n          this.#models.delete(existingModel);\n          // TODO: require the user to explicitly remove the previous model first.\n          // throw new Error(`A model with the name ${inspect(model.name)} was already registered in this Sequelize instance.`);\n        }\n\n        this.#models.add(model);","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/sequelize/sequelize/blob/7e1deec499d5afbb8d1877c2f4d545cead1214ec/packages/core/src/sequelize-typescript.ts#L471-L507","documentation":"The dialect option must be the dialect class itself (a constructor function), not a string like 'mysql' and not an instance. v6 accepted string dialect names; v7 requires importing the class from the dialect package and passing the class reference.","triggerScenarios":"Passing dialect: 'postgres' (string), dialect: someInstance, or grabbing the wrong export from the dialect package.","commonSituations":"v6->v7 migration passing dialect:'sqlite'; default-vs-named import confusion.","solutions":["Import the dialect class and pass it: import { PostgresDialect } from '@sequelize/postgres'; dialect: PostgresDialect.","Pass the class (no parentheses), not an instance of it."],"exampleFix":"// before\nnew Sequelize({ dialect: 'mysql' });\n\n// after\nimport { MySqlDialect } from '@sequelize/mysql';\nnew Sequelize({ dialect: MySqlDialect });","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isDialectClass(v) {\n  return typeof v === 'function' && !!v.prototype;\n}\nif (!isDialectClass(options.dialect)) {\n  throw new Error('options.dialect must be a dialect class');\n}","tryCatchPattern":null,"preventionTips":["Import the named dialect class; do not use string names.","Pass the class reference itself, never an instance."],"tags":["sequelize","dialect","migration","typescript"],"analyzedSha":"7e1deec499d5afbb8d1877c2f4d545cead1214ec","analyzedAt":"2026-08-03T18:58:44.549Z","schemaVersion":2}