📄 Documentation for 20231122151808_IsPdfPortfolioColumn.Designer.cs


🗂️ Table of Contents

  1. Overview & Purpose
  2. EF Core Migration Basics
  3. File Structure
  4. Key Functional Areas
  5. Data Models
  6. Dependencies & Technologies
  7. Using This Migration
  8. PlantUML Class Diagram
  9. Conclusion

1. Overview & Purpose

File:
IrbyImaging.DbContext/Migrations/20231122151808_IsPdfPortfolioColumn.Designer.cs

This is an auto‑generated designer snapshot for an EF Core migration named IsPdfPortfolioColumn. Its primary purpose is to:

  • Capture the entire model state after the migration runs.
  • Help EF Core compute differences between migrations.
  • Ensure the new boolean column IsPdfPortfolio is properly represented on the Ticket entity (mapped to irby.Ticket).

📌 Note: You typically do not modify this file by hand; it is maintained by dotnet ef migrations commands.


2. EF Core Migration Basics

  • Migrations allow incremental schema changes in a code‑first approach.
  • Each migration usually contains two files:
    1. *.cs — Defines the Up and Down methods (actual operations).
    2. *.Designer.cs — Captures a complete snapshot of the model.
  • The Designer file is used internally by EF Core’s diff engine to know the “before” and “after” shapes.

3. File Structure

IrbyImaging.DbContext/
└── Migrations/
    ├── 20231122151808_IsPdfPortfolioColumn.cs         # Migration logic
    └── 20231122151808_IsPdfPortfolioColumn.Designer.cs  # Model snapshot

4. Key Functional Areas

4.1. BuildTargetModel Method

protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
    #pragma warning disable 612, 618
    modelBuilder
        .HasAnnotation("ProductVersion", "7.0.7")
        .HasAnnotation("Relational:MaxIdentifierLength", 128);

    // Configure Identity columns for SQL Server
    SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

    // ... Entities & relationships follow ...
    #pragma warning restore 612, 618
}
  • Purpose: Programmatically rebuild the EF Core model using ModelBuilder.
  • Annotations: Store EF Core version & DB constraints (max identifier length).
  • Pragmas: Silence warnings on obsolete APIs.

4.2. Identity Columns Configuration

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
  • Enables IDENTITY strategy on primary keys for SQL Server.
  • Replaces older UseIdentityColumn & UseHiLo conventions where needed.

4.3. Entity Definitions

  • Over 60+ domain entities are defined, for example:

    modelBuilder.Entity("IrbyImaging.DomainClasses.Ticket", b => {
        b.Property<Guid>("Id")
            .ValueGeneratedOnAdd()
            .HasColumnType("uniqueidentifier");
        // … many other properties …
        b.Property<bool>("IsPdfPortfolio")
            .HasColumnType("bit");        // ← NEW COLUMN
        b.HasKey("Id");
        b.ToTable("Ticket", "irby");
    });
    
  • Discriminator-based TPH (Table‐Per‐Hierarchy) is used for Asset and its subclasses (e.g., Computer, DeskPhone, MobileDevice).


4.4. Relationships & Navigation

  • Foreign Key examples:

    modelBuilder.Entity("IrbyImaging.DomainClasses.Update", b => {
        b.HasOne("IrbyImaging.DomainClasses.Ticket", null)
          .WithMany("Updates")
          .HasForeignKey("TicketId")
          .OnDelete(DeleteBehavior.Cascade);
    });
    
  • Navigation Properties wired up via:

    b.Navigation("Updates");
    

5. Data Models

Entity Table Schema Highlights
Ticket Ticket irby Added IsPdfPortfolio (bit)
Asset Asset irby Base for polymorphic asset subclasses
Employee Employee irby Indexed on JdeNumber
DocumentImage DocumentImage irby Binary/OCR content storage
AuditDetail AuditDetail irby Tracks controllers/actions
… … … 60+ total domain entities

📌 All entities live under IrbyImaging.DomainClasses.


6. Dependencies & Technologies

  • Language: C# 10 / .NET 7
  • ORM: Microsoft.EntityFrameworkCore (v7.0.7)
  • Provider: Microsoft.EntityFrameworkCore.SqlServer
  • Tooling: dotnet ef CLI, Visual Studio / Rider

7. Using This Migration

7.1. Apply Migration

# Applies all pending migrations (including IsPdfPortfolioColumn)
dotnet ef database update

7.2. Rollback Migration

# Revert to one migration earlier
dotnet ef database update 20231122120000_PreviousMigration

8. PlantUML Class Diagram

@startuml
package Migrations {
  class MyMigration <<abstract>> {
    +Up()
    +Down()
  }
  class IsPdfPortfolioColumn <<MyMigration>> {
    +BuildTargetModel(modelBuilder)
  }
  MyMigration <|-- IsPdfPortfolioColumn
}

package Domain {
  class Ticket {
    +Guid Id
    +bool IsPdfPortfolio
    +ICollection<Update> Updates
  }
  class Update {
    +Guid Id
    +string Description
    +DateTime Timestamp
  }
  Ticket "1" *-- "0..*" Update : has
}
@enduml

⚙️ This diagram illustrates the migration class hierarchy and the Ticket–Update relationship.


9. Conclusion

  • The Designer.cs file is a critical snapshot for EF Core’s migration engine.
  • It ensures the new IsPdfPortfolio column on Ticket is accurately reflected in the model.
  • Do not manually edit this file; use dotnet ef migrations add / dotnet ef database update to manage schema changes.

Happy coding with EF Core! 🎉