πŸ“‘ Documentation: 20220608152519_MoreColumnsForLegalImaging.cs


πŸ—‚ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Key Functional Areas
  4. Schema Changes Summary
  5. UML Class Diagram
  6. Sample Usage & Commands
  7. Error Handling & Return Types
  8. Third‑Party Integrations
  9. Conclusion

🧐 Overview & Purpose

This migration adds a new AttributeType column to the DocumentAttribute table within the irby schema.
It is part of the IrbyImaging.DbContext.Migrations assembly and is intended to enhance the Legal Imaging feature by categorizing document attributes.

  • Filename: 20220608152519_MoreColumnsForLegalImaging.cs
  • Created/Modified: 06-08-2022 by kvamshi
  • Migration ID: 20220608152519

πŸ”§ Dependencies & Technologies

Component Version / Info
.NET / C# .NET Core / .NET 5+
Microsoft.EntityFrameworkCore.Migrations EF Core Migrations API
SQL Database Target relational database (e.g., SQL Server)
Assembly IrbyImaging.DbContext

πŸš€ Key Functional Areas

3.1 Migration Class Structure

public partial class MoreColumnsForLegalImaging : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)  { ... }
    protected override void Down(MigrationBuilder migrationBuilder){ ... }
}
  • Inherits from Migration (EF Core).
  • Contains two core methods:
    • Up: Applies changes to the database schema.
    • Down: Reverts those changes.

3.2 Up Method

Purpose: Add a new column AttributeType to the DocumentAttribute table.

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.AddColumn<int>(
        name: "AttributeType",
        schema: "irby",
        table: "DocumentAttribute",
        type: "int",
        nullable: false,
        defaultValue: 0
    );
}
  • name: "AttributeType"
  • schema: "irby"
  • table: "DocumentAttribute"
  • type: "int"
  • nullable: false
  • defaultValue: 0

✨ Note: Setting nullable: false with a defaultValue ensures existing records get 0 for the new column.

3.3 Down Method

Purpose: Remove the previously added column.

protected override void Down(MigrationBuilder migrationBuilder)
{
    migrationBuilder.DropColumn(
        name: "AttributeType",
        schema: "irby",
        table: "DocumentAttribute"
    );
}
  • Reverses the AddColumn operation.
  • Ensures clean rollback if migration is undone.

πŸ“Š Schema Changes Summary

4.1 Before Migration

Column Name Data Type Nullable?
Id int No
DocumentId int No
Name nvarchar Yes
Value nvarchar Yes
(no AttributeType)

4.2 After Migration

Column Name Data Type Nullable? Default Value
Id int No –
DocumentId int No –
Name nvarchar Yes –
Value nvarchar Yes –
AttributeType int No 0

πŸ“ UML Class Diagram

+------------------------------------------------+
|       MoreColumnsForLegalImaging : Migration   |
+------------------------------------------------+
| - (inherits Migration)                         |
+------------------------------------------------+
| + Up(migrationBuilder: MigrationBuilder) : void|
| + Down(migrationBuilder: MigrationBuilder) : void|
+------------------------------------------------+

🧰 Sample Usage & Commands

  1. Add Migration
    dotnet ef migrations add MoreColumnsForLegalImaging
    
  2. Apply Migration
    dotnet ef database update
    
  3. Rollback Migration
    dotnet ef database update [PreviousMigrationName]
    

βœ”οΈ After running, check the DocumentAttribute table under the irby schema for the new column.


⚠️ Error Handling & Return Types

  • Return Type: Both Up and Down methods return void.
  • Error Handling:
    • EF Core will throw exceptions (e.g., SqlException) if the migration fails (e.g., naming conflicts, permission issues).
    • Ensure database user has ALTER permissions.

🌐 Third‑Party Integrations

  • Microsoft.EntityFrameworkCore
    Utilizes the EF Core migrations engine.
  • SQL Providers
    Works with any EF Core–supported database (e.g., SQL Server, PostgreSQL). The type: "int" may vary based on the provider.

✨ Conclusion

This migration enhances the Legal Imaging domain by introducing an AttributeType discriminator for document attributes.
By following standard EF Core migration patterns, it ensures both forward (Up) and backward (Down) compatibility.

πŸš€ Next Steps:

  • Adjust application code to use AttributeType when processing DocumentAttribute entities.
  • Update business logic, APIs, or UI to leverage the new column.

Generated by the Irby Imaging team documentation generator. πŸ“