📘 Documentation: 20230925183034_RequestExecutionProcessColumns.Designer.cs

Location:
IrbyImaging.DbContext/Migrations/20230925183034_RequestExecutionProcessColumns.Designer.cs


📖 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Key Functional Areas
  4. Data Model Entities
  5. Building the Target Model
  6. Relationships & Constraints
  7. Migration Workflow & Usage
  8. UML Class Diagram (Mermaid)
  9. Conclusion

1. Overview & Purpose

This file is an auto-generated snapshot of the Entity Framework Core model at the point in time when the RequestExecutionProcessColumns migration was created. It lives alongside the Up/Down methods in the migration code, and its primary job is to:

  • 🔧 Define every entity, its properties, indexes and relationships
  • 🗄️ Map your C# domain classes (IrbyImaging.DomainClasses.*) to database tables and schemas
  • 📦 Capture the database schema state so EF Core can compare “before” and “after” for subsequent migrations

Tip: You should never manually edit this file. It is regenerated whenever you add a new migration.


2. Dependencies & Technologies

Component Version
.NET SDK 7.0.x
Microsoft.EntityFrameworkCore 7.0.7
Microsoft.EntityFrameworkCore.SqlServer 7.0.7
C# Language Features 10 / 11

3. Key Functional Areas

  1. Model Annotation
    • .HasAnnotation("ProductVersion", "7.0.7")
    • .HasAnnotation("Relational:MaxIdentifierLength", 128)
  2. Identity Columns
    • SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder)
  3. Entity Definitions
    • For each domain class, EF configures:
      • Properties (.HasColumnType(), .IsRequired(), .ValueGeneratedOnAdd(), etc.)
      • Keys (.HasKey())
      • Indexes (.HasIndex())
      • Discriminators for inheritance (TPT/TPC/TPH strategies)
  4. Relationships
    • One‑to‑many, many‑to‑one, cascade rules, navigation properties

4. Data Model Entities

🛠 Asset & Equipment

Entity Table (Schema.Table) Notes
Asset irby.Asset Base class for all physical assets
Computer irby.Asset Inherits Asset; adds OS, CPS, AssetNumber, UnitNumber
DeskPhone irby.Asset Adds MacAddress, PhoneNumber
Dock irby.Asset (no extra props)
MobileDevice irby.Asset IMSI/IMEI, Carrier, Sim, PhoneNumber
Monitor irby.Asset (no extra props)
NetworkEquipment irby.Asset (no extra props)
OfficePrinter irby.Asset Company, ContractEndDate
Printer irby.Asset (no extra props)
SafetyEquipment irby.Asset AssetNumber, CPSNumber, OS, UnitNumber
AssetModel irby.AssetModel Defines model metadata, foreign‑key to Manufacturer
Manufacturer irby.AssetManufacturer Who makes the model
OperatingSystem irby.OperatingSystem OS options
AssetHistory irby.AssetHistory Tracks changes over time

📚 Documents

Entity Table (Schema.Table) Notes
DocumentImage irby.DocumentImage Stores images, OCR text & pages
DocumentType irby.DocumentType Catalog of types
DocumentCategory irby.DocumentCategory Grouping of types
DocumentAttribute irby.DocumentAttribute Defines meta‑data fields
BlobData irby.BlobData Temporary binary storage
TempDocumentData irby.TempDocumentData Staging area before final indexing
IPMMigration irby.IPMMigration Legacy import tracking
IrbyForms irby.IrbyForms Static forms repository

👥 Human Resources & Security

Entity Table (Schema.Table) Notes
Employee irby.Employee Core user/employee record
Department irby.Department Org units
Role irby.Role Security roles
Permissions irby.Permissions Fine‑grained actions
LinkUserRole irby.LinkUserRole M‑to‑N: Employees ↔ Roles
LinkRolePermission irby.LinkRolePermission M‑to‑N: Roles ↔ Permissions
AuditDetail irby.AuditDetail Tracks user actions
TimeEntryType irby.TimeEntryType e.g. Regular, Overtime
TimeSheetEntry irby.TimeSheetEntry Daily hours logged

🏗 Operational & Billing

Entity Table (Schema.Table) Notes
FieldOffice irby.FieldOffice Geographical branch
Job irby.Job Project/work order
Customer irby.Customer Client master
BillingInvoice irby.BillingInvoice Invoicing details
Issue irby.Issue Problem/ticket type
Ticket irby.Ticket Service requests
Update irby.Update Ticket status history
RequestOption irby.RequestOption Configurable request items

🌐 ODS Integration

Entity Table (Schema.Table) Notes
ODSCustomer ODSCustomers External ODS customer data
ODSEmployee ODSEmployees External ODS HR data
ODSJob ODSJobs External ODS job/project data

5. Building the Target Model

At the heart of this file is the override:

[DbContext(typeof(IrbyContext))]
[Migration("20230925183034_RequestExecutionProcessColumns")]
partial class RequestExecutionProcessColumns
{
    protected override void BuildTargetModel(ModelBuilder modelBuilder)
    {
        modelBuilder
            .HasAnnotation("ProductVersion", "7.0.7")
            .HasAnnotation("Relational:MaxIdentifierLength", 128);

        SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

        // → Entity definitions follow…
    }
}
  • ModelBuilder is used to register each entity type.
  • Property calls configure column names, types, and nullability.
  • HasKey & HasIndex set primary keys and indexes.
  • ToTable maps CLR types to physical tables (often under schema irby).
  • HasDiscriminator implements Table‑Per‑Hierarchy (TPH) for asset subtypes.

6. Relationships & Constraints

  • One‑to‑Many
    modelBuilder.Entity<Asset>()
        .HasOne(a => a.Owner)
        .WithMany(e => e.Assets)
        .HasForeignKey(a => a.OwnerId);
    
  • Cascade Delete
    modelBuilder.Entity<AssetModel>()
        .HasOne(m => m.Make)
        .WithMany(mf => mf.Models)
        .HasForeignKey(m => m.MakeId)
        .OnDelete(DeleteBehavior.Cascade);
    
  • Unique Indexes
    modelBuilder.Entity<Employee>()
        .HasIndex(e => e.JdeNumber)
        .IsUnique()
        .HasFilter("[JdeNumber] IS NOT NULL");
    

Each navigation property and foreign‑key is meticulously configured, ensuring data integrity.


7. Migration Workflow & Usage

  1. Generate Migration
    dotnet ef migrations add RequestExecutionProcessColumns
    
  2. Inspect Designer File
    • Confirms your model snapshot matches code changes.
  3. Apply to Database
    dotnet ef database update
    
  4. Rollback
    dotnet ef database update LastGoodMigration
    

8. UML Class Diagram (Mermaid)

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

    AssetModel "1" o-- "0..*" Asset : hasModel
    Manufacturer "1" o-- "0..*" AssetModel : produces
    Employee "1" o-- "0..*" Asset : owns
    FieldOffice "1" o-- "0..*" Asset : locatedAt

    Employee "1" o-- "0..*" TimeSheetEntry : logs
    TimeEntryType "1" o-- "0..*" TimeSheetEntry : ofType

    Job "1" o-- "0..*" Employee : employs
    Role "1" o-- "0..*" LinkUserRole : grants

9. Conclusion

This Designer file is an indispensable part of the EF Core migrations pipeline. It captures the complete mapping of your domain model to the database schema. Whenever your C# classes or relationships change, regenerating this snapshot ensures consistent, repeatable schema evolution—without “drift.”

🚀 Happy migrating!