{"record":{"id":"b22ff202a9c7dffe","repo":"dotnet/efcore","slug":"sql-generation-for-the-operation-operation-is","errorCode":null,"errorMessage":"SQL generation for the operation '{operation}' is not supported by the current database provider. Database providers must implement the appropriate method in 'MigrationsSqlGenerator' to support this operation.","messagePattern":"SQL generation for the operation '(.+?)' is not supported by the current database provider\\. Database providers must implement the appropriate method in 'MigrationsSqlGenerator' to support this operation\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs","lineNumber":310,"sourceCode":"        EndStatement(builder);\n    }\n\n    /// <summary>\n    ///     Can be overridden by database providers to build commands for the given <see cref=\"AlterColumnOperation\" />\n    ///     by making calls on the given <see cref=\"MigrationCommandListBuilder\" />.\n    /// </summary>\n    /// <remarks>\n    ///     Note that the default implementation of this method throws <see cref=\"NotSupportedException\" />. Providers\n    ///     must override if they are to support this kind of operation.\n    /// </remarks>\n    /// <param name=\"operation\">The operation.</param>\n    /// <param name=\"model\">The target model which may be <see langword=\"null\" /> if the operations exist without a model.</param>\n    /// <param name=\"builder\">The command builder to use to build the commands.</param>\n    protected virtual void Generate(\n        AlterColumnOperation operation,\n        IModel? model,\n        MigrationCommandListBuilder builder)\n        => throw new NotSupportedException(RelationalStrings.MigrationSqlGenerationMissing(nameof(AlterColumnOperation)));\n\n    /// <summary>\n    ///     Can be overridden by database providers to build commands for the given <see cref=\"AlterDatabaseOperation\" />\n    ///     by making calls on the given <see cref=\"MigrationCommandListBuilder\" />.\n    /// </summary>\n    /// <remarks>\n    ///     Note that there is no default implementation of this method. Providers must override if they are to\n    ///     support this kind of operation.\n    /// </remarks>\n    /// <param name=\"operation\">The operation.</param>\n    /// <param name=\"model\">The target model which may be <see langword=\"null\" /> if the operations exist without a model.</param>\n    /// <param name=\"builder\">The command builder to use to build the commands.</param>\n    protected virtual void Generate(\n        AlterDatabaseOperation operation,\n        IModel? model,\n        MigrationCommandListBuilder builder)\n    {\n    }","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs#L292-L328","documentation":"Default implementation of Generate(AlterColumnOperation, ...) throws NotSupportedException. AlterColumnOperation is relational but not every provider implements column-alter SQL the same way, so the base class makes the provider opt in. The provider package must override this method to support migrations that alter columns.","triggerScenarios":"A migration calls migrationBuilder.AlterColumn<T>(...) and the active provider's MigrationsSqlGenerator did not override the AlterColumn Generate method (rare for shipping providers like SqlServer/Postgres, common for minimal/custom providers or a very old provider version).","commonSituations":"Using a community/in-progress database provider that has not implemented AlterColumn yet; running migrations generated for one provider against a stub provider in tests; provider package version mismatch after an EF Core upgrade.","solutions":["Upgrade the database provider package to one that implements AlterColumnOperation support.","If you maintain the provider, override Generate(AlterColumnOperation, IModel, MigrationCommandListBuilder).","As a workaround, drop and re-add the column instead of altering it (data loss risk — back up first)."],"exampleFix":"// before — provider lacks AlterColumn; migration throws\nmigrationBuilder.AlterColumn<string>(\"Email\", \"Users\", maxLength: 200);\n\n// workaround — drop + recreate (provider supports these)\nmigrationBuilder.DropColumn(\"Email\", \"Users\");\nmigrationBuilder.AddColumn<string>(\"Email\", \"Users\", maxLength: 200);\n\n// proper fix — implement in the provider\nclass MyProviderSqlGenerator : MigrationsSqlGenerator\n{\n    protected override void Generate(\n        AlterColumnOperation op, IModel? model, MigrationCommandListBuilder b)\n    {\n        // emit provider-specific ALTER COLUMN ...\n    }\n}","handlingStrategy":"validation","validationCode":"// Detect provider support for AlterColumnOperation before running\nvar gen = db.GetService<IMigrationsSqlGenerator>().GetType();\nbool supportsAlter = gen.GetMethod(\"Generate\",\n    BindingFlags.Instance | BindingFlags.NonPublic,\n    null, CallingConventions.Any,\n    new[] { typeof(AlterColumnOperation), typeof(IModel), typeof(MigrationCommandListBuilder) },\n    null)?.DeclaringType != typeof(MigrationsSqlGenerator);","typeGuard":"null","tryCatchPattern":null,"preventionTips":["Choose a provider package version known to support the operations your migrations use.","For custom providers, implement every Generate override you might emit.","Run migrations against a real provider (not a stub) in integration tests."],"tags":["migrations","sql-generation","provider","alter-column"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}