{"record":{"id":"c4358d523af4c174","repo":"dotnet/efcore","slug":"the-down-method-for-this-migration-has-not-been","errorCode":null,"errorMessage":"The 'Down' method for this migration has not been implemented. Both the 'Up' and 'Down' methods must be implemented to support reverting migrations.","messagePattern":"The 'Down' method for this migration has not been implemented\\. Both the 'Up' and 'Down' methods must be implemented to support reverting migrations\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/Migration.cs","lineNumber":142,"sourceCode":"    ///     Builds the operations that will migrate the database 'down'.\n    /// </summary>\n    /// <remarks>\n    ///     <para>\n    ///         That is, builds the operations that will take the database from the state left in by\n    ///         this migration so that it returns to the state that it was in before this migration was applied.\n    ///     </para>\n    ///     <para>\n    ///         This method must be overridden in each class that inherits from <see cref=\"Migration\" /> if\n    ///         both 'up' and 'down' migrations are to be supported. If it is not overridden, then calling it\n    ///         will throw and it will not be possible to migrate in the 'down' direction.\n    ///     </para>\n    ///     <para>\n    ///         See <see href=\"https://aka.ms/efcore-docs-migrations\">Database migrations</see> for more information and examples.\n    ///     </para>\n    /// </remarks>\n    /// <param name=\"migrationBuilder\">The <see cref=\"MigrationBuilder\" /> that will build the operations.</param>\n    protected virtual void Down(MigrationBuilder migrationBuilder)\n        => throw new NotSupportedException(RelationalStrings.MigrationDownMissing);\n\n    private List<MigrationOperation> BuildOperations(Action<MigrationBuilder> buildAction)\n    {\n        var migrationBuilder = new MigrationBuilder(ActiveProvider);\n        buildAction(migrationBuilder);\n\n        return migrationBuilder.Operations;\n    }\n}\n","sourceCodeStart":124,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Migrations/Migration.cs#L124-L152","documentation":"Thrown by the base `Migration.Down(MigrationBuilder)` when a derived migration did not override `Down`. EF requires both `Up` and `Down` to revert migrations; calling rollback/downgrade on a migration with only `Up` implemented throws `NotSupportedException`.","triggerScenarios":"Running `dotnet ef database update <previous>` (or `Migrate(targetMigration)`) targeting a migration whose class only overrides `Up`. The migrator invokes `Down` to revert, hitting the base throw.","commonSituations":"Hand-written or generated migrations that only filled in `Up`; partial migration generation; attempting to roll back a migration that was never intended to be reverted.","solutions":["Override `Down(MigrationBuilder)` in the migration class with the reverse operations.","If rollback is not required, migrate forward to a newer migration instead of reverting.","Regenerate the migration with `dotnet ef migrations add` which scaffolds both `Up` and `Down`."],"exampleFix":"// before\npublic partial class AddFoo : Migration\n{\n    protected override void Up(MigrationBuilder migrationBuilder)\n        => migrationBuilder.AddColumn<int>(\"Foo\", \"Bars\");\n}\n// after\nprotected override void Down(MigrationBuilder migrationBuilder)\n    => migrationBuilder.DropColumn(\"Foo\", \"Bars\");","handlingStrategy":"validation","validationCode":"// Static check: every migration class in the assembly overrides Down.\nforeach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(Migration).IsAssignableFrom(t) && !t.IsAbstract))\n{\n    var down = type.GetMethod(nameof(Migration.Down), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);\n    if (down is null) throw new InvalidOperationException($\"{type.Name} does not override Down; rollback unsupported.\");\n}","typeGuard":"bool HasDownOverride(Type migrationType)\n    => migrationType.GetMethod(nameof(Migration.Down),\n        BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) is not null;","tryCatchPattern":null,"preventionTips":["Always implement `Down` when authoring migrations; prefer `dotnet ef migrations add` which scaffolds both.","Add a test asserting every migration overrides `Down` before allowing rollback."],"tags":["efcore","migrations","rollback","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}