🗂️ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Migration Class: NewColumnsForLegalImaging
  4. The BuildTargetModel Method
  5. Entities & Data Models
    5.1. Asset & Derived Types
    5.2. Document Entities
    5.3. Employee & Organizational Entities
    5.4. Supporting/Lookup Entities
  6. Relationships & Navigation Properties
  7. How to Use This Migration
  8. UML Diagram (Simplified)
  9. Conclusion

1. Overview & Purpose

File:
IrbyImaging.DbContext/Migrations/20220608134423_NewColumnsForLegalImaging.Designer.cs

Purpose:
This auto‑generated EF Core migration designer file captures the snapshot of the Entity Framework Core model after applying the NewColumnsForLegalImaging migration.

  • 🔍 It defines metadata—tables, columns, keys, indexes, relationships and discriminators.
  • ⚙️ It is used by EF Core at runtime to compare the current model to the target model and to generate further migrations.

2. Dependencies & Technologies

Dependency Version / Notes
Microsoft.EntityFrameworkCore 5.0.12
Microsoft.EntityFrameworkCore.SqlServer Underlying provider (SQL Server)
Microsoft.EntityFrameworkCore.Design Tools for migrations
.NET Core framework for IServiceCollection etc.
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.12">
  <PrivateAssets>all</PrivateAssets>
</PackageReference>

3. Migration Class: NewColumnsForLegalImaging

[DbContext(typeof(IrbyContext))]
[Migration("20220608134423_NewColumnsForLegalImaging")]
partial class NewColumnsForLegalImaging : Migration
{
    protected override void BuildTargetModel(ModelBuilder modelBuilder)
    {
        //...
    }
}
  • Namespace: IrbyImaging.DbContext.Migrations
  • Annotations:
    • Relational:MaxIdentifierLength: Limits table/column name lengths.
    • ProductVersion: EF Core version.
    • SqlServer:ValueGenerationStrategy: Identity columns by default.

4. The BuildTargetModel Method

This method reconstructs the entire EF Core model after this migration:

  • Registers each entity type (domain class) with its table mapping.
  • Defines properties → columns (type, precision, required vs. nullable).
  • Configures keys, indexes, discriminators (for TPH inheritance).
  • Sets up relationships and navigation.
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
    // 1. Global annotations
    modelBuilder
      .HasAnnotation("Relational:MaxIdentifierLength", 128)
      .HasAnnotation("ProductVersion", "5.0.12")
      .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

    // 2. Entity registrations
    modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => { ... });
    modelBuilder.Entity("IrbyImaging.DomainClasses.DocumentImage", b => { ... });
    // ... (many more)

    // 3. Relationship wiring
    modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
      b.HasOne("IrbyImaging.DomainClasses.FieldOffice", "FieldOffice")
       .WithMany("Assets")
       .HasForeignKey("FieldOfficeId");
      // ...
    });
}

5. Entities & Data Models

Below is a summary of key entities defined in this migration. We group them for readability.

5.1. Asset & Derived Types 🚗💻📱

Entity Table Key Discriminator Special Columns
Asset irby.Asset Id:GUID Asset Category, FieldOfficeId, ModelId, OwnerId…
Computer irby.Asset inherits Computer AssetNumber, CpsNumber, OperatingSystemId…
MobileDevice irby.Asset inherits MobileDevice Carrier, Imei (unique), PhoneNumber, Sim…
DeskPhone irby.Asset inherits DeskPhone MacAddress, PhoneNumber
OfficePrinter irby.Asset inherits OfficePrinter Company, ContractEndDate
SafetyEquipment irby.Asset inherits SafetyEquipment AssetNumber, CpsNumber, OperatingSystemId…

5.2. Document Entities 📝📷

Entity Table Key Columns
DocumentImage irby.DocumentImage DocumentImageId FileName, ImageContents, OCRText…
TempDocumentData irby.TempDocumentData TempDocumentDataId ContentType, Page, ReferenceId…
IPMMigration irby.IPMMigration IPMMigrationId BatchId, IsIndexed, TotalPages…
IrbyForms irby.IrbyForms FormId FormName, FormNumber, ImageContents…
DocumentType irby.DocumentType Id Type, Description, IsDeleted…
DocumentAttribute irby.DocumentAttribute Id AttributeName, DocumentType, Values…

5.3. Employee & Organizational Entities 👩‍💼🏢

Entity Table Key Columns
Employee irby.Employee Id:GUID DisplayName, Email, JdeNumber(unique)
FieldOffice irby.FieldOffice Id:GUID Name, JdeNumber(unique), ManagerId…
Job irby.Job Id:GUID Name, JdeNumber(unique)
ODS_Employee_Staging irby.ODS_Employee_Staging EMPLOYEE_NUMBER FIRST_NAME, ORG_BU(alternate key)
ODS_Jobs_Staging irby.ODS_Jobs_Staging ORG_BU NAME

5.4. Supporting/Lookup Entities 🔎

Entity Table Key Columns
CarrierType irby.CarrierType Id:GUID Carrier, IsInactive
CarrierTypeDetail irby.CarrierTypeDetail Id CarrierTypeId → FK, IsInactive
GeneralLedger irby.GeneralLedger Id Code, Description
GLTypeDetail irby.GLTypeDetail Id GeneralLedgerId → FK, Code, IsInactive
BillingInvoice irby.BillingInvoice Id:GUID Charge, InvoiceYearMonth, JDENumber…
Issue irby.Issue Id:GUID Description
Ticket & Update irby.Ticket, irby.Update Id:GUID TicketNumber, Status; Update → TicketId
Manufacturer irby.AssetManufacturer Id:int Name, WarrantyMonths
AssetModel & Detail irby.AssetModel, AssetModelDetail Id Category, MakeId → FK
OperatingSystem irby.OperatingSystem Id Name, IsAvailableOption
RequestOption irby.RequestOption Id Type, Item, Cost

6. Relationships & Navigation Properties 🔗

  • One‑to‑Many

    • Asset → AssetHistory
    • Employee → Assets
    • Job → Employees
    • FieldOffice → Assets
    • Ticket → Updates
  • Many‑to‑One

    • Asset ↔ FieldOffice (FK FieldOfficeId)
    • Asset ↔ AssetModel (FK ModelId)
    • Employee ↔ Job (FK CurrentJobId)
  • One‑to‑One / Unique Index

    • Employee.JdeNumber (unique, not null)
    • FieldOffice.JdeNumber (unique)
    • MobileDevice.Imei (unique)

Example of relationship configuration:

modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
  b.HasOne("IrbyImaging.DomainClasses.FieldOffice", "FieldOffice")
   .WithMany("Assets")
   .HasForeignKey("FieldOfficeId");
});

7. How to Use This Migration ⚙️

  1. Add Migration

    dotnet ef migrations add NewColumnsForLegalImaging
    
  2. Update Database

    dotnet ef database update
    
  3. Rollback (if needed)

    dotnet ef database update LastGoodMigration
    

Note: This designer file is auto‑generated; do not edit it manually. Instead, modify your DbContext or entity classes, then add a new migration.


8. UML Diagram (Simplified) 📊

@startuml
class Asset {
  +Guid Id
  +string Category
  +int ModelId
  +Guid? FieldOfficeId
  +Guid? OwnerId
}
class Computer <<Asset>> {
  +string AssetNumber
  +int OperatingSystemId
}
class MobileDevice <<Asset>> {
  +string Imei
  +bool IsTelogis
}
class FieldOffice {
  +Guid Id
  +string Name
}
class AssetModel {
  +int Id
  +string Category
}
Asset --> FieldOffice : FieldOfficeId
Asset --> AssetModel : ModelId
Computer --> OperatingSystem
MobileDevice --> ? // no direct FK
@enduml

A more complete UML can be generated using EF Core Power Tools.


9. Conclusion ✅

  • This designer snapshot captures your full EF Core model state for the migration NewColumnsForLegalImaging.
  • It ensures that EF Core can diff future changes and maintain schema consistency.
  • Always keep your domain classes and your migrations in sync to avoid runtime errors.

Enjoy your beautifully documented EF Core migration! 🚀