How can you customize migrations (e.g. modify Up/Down methods, custom SQL)?
You can manually edit migration files after scaffolding:
protected override void Up(MigrationBuilder migrationBuilder)
migrationBuilder.Sql("UPDATE Users SET IsActive = 1 WHERE
IsActive IS NULL");
- Add indexes, constraints, stored procedures.
- Use raw SQL or Fluent API.
- Be cautious to maintain idempotency and correctness.
Entity Framework Core – Change
Tracking & Concurrency