📄 Documentation: 20220608152519_MoreColumnsForLegalImaging.Designer.cs

File Path:
IrbyImaging.DbContext/Migrations/20220608152519_MoreColumnsForLegalImaging.Designer.cs

Assembly: IrbyImaging.DbContext
Author: kvamshi
Created/Modified: 06‑08‑2022


📑 Table of Contents

  1. Introduction
  2. Purpose & Overview
  3. EF Core Migrations at a Glance
  4. File Structure & Key Attributes
  5. BuildTargetModel Method Deep Dive
  6. Entities & Data Models
  7. Relationships & Fluent API Configuration
  8. Key Changes in This Migration
  9. How to Apply & Use This Migration
  10. Mermaid UML Diagram
  11. Conclusion

1. Introduction

Welcome to the generated snapshot of MoreColumnsForLegalImaging—an Entity Framework Core (EF Core) migration designer file. This file contains the complete model definition as of the 20220608152519 migration. It is auto‑generated by EF Core to support database schema changes while preserving model compatibility.


2. Purpose & Overview

✨ Purpose:

  • Provide a model snapshot that EF Core uses to compute differences between your C# domain classes and the target database schema.
  • Ensure that subsequent migrations can build upon this exact state of the model.

🔍 Overview:

  • Defines all entity types, their properties, keys, indices, table mappings, discriminators (for TPH inheritance), and relationships.
  • Critical for supporting the Up() and Down() methods found in the corresponding .cs migration file.

3. EF Core Migrations at a Glance

  • Migrations track incremental changes to your model.
  • A migration typically consists of:
    • <timestamp>_MoreColumnsForLegalImaging.cs → Contains Up() / Down() to apply or revert schema changes.
    • <timestamp>_MoreColumnsForLegalImaging.Designer.cs → Contains BuildTargetModel() with the model snapshot.

👍 Why the Designer file matters:

  1. Model Consistency
  2. Future Diffs
  3. Scaffolding

4. File Structure & Key Attributes

[DbContext(typeof(IrbyContext))]
[Migration("20220608152519_MoreColumnsForLegalImaging")]
partial class MoreColumnsForLegalImaging : Migration
{
    protected override void BuildTargetModel(ModelBuilder modelBuilder)
    {
        // ... fluent configuration ...
    }
}
  • [DbContext(typeof(IrbyContext))]
    Associates this migration with the IrbyContext.
  • [Migration("20220608152519_MoreColumnsForLegalImaging")]
    Uniquely identifies the migration by timestamp and name.
  • partial class MoreColumnsForLegalImaging : Migration
    Extends EF Core’s Migration base type.

5. BuildTargetModel Method Deep Dive

The heart of this file is the fluent configuration of your entire domain model:

modelBuilder
  .HasAnnotation("Relational:MaxIdentifierLength", 128)
  .HasAnnotation("ProductVersion", "5.0.12")
  .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

// Example: Asset entity
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
    b.Property<Guid>("Id")
     .ValueGeneratedOnAdd()
     .HasColumnType("uniqueidentifier");

    b.Property<string>("Category")
     .IsRequired()
     .HasColumnType("nvarchar(max)");

    // ... other Asset properties ...

    b.HasKey("Id");
    b.ToTable("Asset", "irby");
    b.HasDiscriminator<string>("Discriminator").HasValue("Asset");
});
  • Global Annotations:
    • MaxIdentifierLength (128)
    • EF Core ProductVersion
    • SQL Server identity strategy
  • Entity Definitions:
    • Properties: Data types, nullability, length
    • Keys: Primary keys via HasKey(...)
    • Indices: HasIndex(...)
    • Table & Schema Mapping: ToTable("Name","Schema")
    • Inheritance Mapping: HasDiscriminator<T>("...")

6. Entities & Data Models

Below is a simplified list of core entities introduced or modified in this snapshot:

Entity Table (Schema) PK Notes
Asset irby.Asset Id (GUID) TPH base for IT assets
├─ Computer irby.Asset Id + AssetNumber, OperatingSystemId
├─ MobileDevice irby.Asset Id + Imei (unique), Carrier
├─ DeskPhone, Printer, etc. irby.Asset Id Various discriminators
AssetModel irby.AssetModel Id (int) FK → Manufacturer
AssetModelDetail dbo.AssetModelDetail Id (int) FK → AssetModel, Make
FieldOffice irby.FieldOffice Id (GUID) Relationships to Employee
Employee irby.Employee Id (GUID) Unique Index on JdeNumber
Job irby.Job Id (GUID) Unique Index on JdeNumber
DocumentImage irby.DocumentImage DocumentImageId (GUID) NEW columns for legal imaging
… and many more (Tickets, Updates, CovidTestData, etc.)

ℹ️ Tip: The full code lists 40+ entities. Use your IDE’s Go To Definition to explore each.


7. Relationships & Fluent API Configuration

🔗 Key Foreign Keys

Principal Entity Navigation Property Dependent Entity FK Field OnDelete
AssetModel → Make Make AssetModel MakeId Cascade
Asset → Model Model Asset ModelId Cascade
Asset → Owner Owner Asset OwnerId (no cascade)
Employee → Job CurrentJob Employee CurrentJobId Cascade
DocumentImage (no nav) (flat properties) – –
Ticket → Updates Updates Update TicketId Cascade

After properties & keys, the designer file wires up navigation properties:

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

8. Key Changes in This Migration

While the Designer file is a snapshot—not the diffs—the migration name suggests “More Columns For Legal Imaging.” Likely additions include:

  • DocumentImage
    • DocumentCategory (nvarchar)
    • DocumentNotes (nvarchar)
    • DocumentType (nvarchar)
    • OriginalReferenceId (GUID)
    • TotalPages, Page fields (int)

These enable capturing additional metadata for legal imaging workflows.


9. How to Apply & Use This Migration

  1. Add the Migration (already done):
    dotnet ef migrations add MoreColumnsForLegalImaging
    
  2. Update Database:
    dotnet ef database update 20220608152519_MoreColumnsForLegalImaging
    
  3. In Code:
    using (var context = new IrbyContext())
    {
        context.Database.Migrate();
        // Now you can CRUD DocumentImage with the new columns:
        var doc = new DocumentImage {
          FileName = "contract.pdf",
          DocumentCategory = "Legal",
          DocumentNotes = "Signed by counsel",
          // …
        };
        context.Add(doc);
        context.SaveChanges();
    }
    

10. Mermaid UML Diagram

classDiagram
  Asset <|-- Computer
  Asset <|-- MobileDevice
  Asset <|-- DeskPhone
  Asset <|-- Printer
  Asset <|-- OfficePrinter
  Asset <|-- Monitor
  Asset <|-- NetworkEquipment
  Asset <|-- SafetyEquipment

  AssetModel --> Manufacturer : Make
  AssetModel --> AssetModelDetail : AssetsModelDetail
  Asset --> AssetHistory : AssetHistories
  Employee --> Job : CurrentJob
  FieldOffice --> Employee : Manager, ProjectManager, Superintendent
  Ticket --> Update : Updates

11. Conclusion

This Designer file is a structural blueprint of your EF Core model at the point when MoreColumnsForLegalImaging was created. It:

  • Ensures reliable diffs for future migrations.
  • Captures all entities, properties, keys, indices, and relationships.
  • Reflects new legal‑imaging metadata columns for DocumentImage.

⚠️ Do not manually edit this file—let EF Core manage it. For schema changes, modify your domain classes and generate a new migration.

Happy coding! 🚀