📑 Table of Contents

  1. Overview & Purpose
  2. Migration Details
  3. BuildTargetModel Explained
  4. Domain Entities & Data Models
  5. Entity Relationship Diagram (UML)
  6. Dependencies & Technologies
  7. Usage & Examples
  8. Best Practices
  9. Conclusion

🔍 Overview & Purpose

File:
IrbyImaging.DbContext/Migrations/20230711141837_RemoveHrColumns.Designer.cs

This is an auto-generated EF Core migration designer file. It represents the target database schema after applying the RemoveHrColumns migration.

ℹ️ Note: Designer files mirror your C# model into a database snapshot. Do not edit manually—they are regenerated on each dotnet ef migrations add command.

Key Goals:

  • Capture all entities, properties, keys and relationships of your domain at this migration point.
  • Drive Update-Database or dotnet ef database update to sync the database.

🛠️ Migration Details

Attribute Value
Migration ID 20230711141837_RemoveHrColumns
DbContext IrbyContext
Target .NET / EF Core Version .NET 7.0 / EF Core 7.0.7
Database Provider Microsoft.EntityFrameworkCore.SqlServer
[DbContext(typeof(IrbyContext))]
[Migration("20230711141837_RemoveHrColumns")]
partial class RemoveHrColumns
{
    protected override void BuildTargetModel(ModelBuilder modelBuilder)
    {
        // .. entity configurations
    }
}

🏗️ BuildTargetModel Explained

The BuildTargetModel method rebuilds your model snapshot:

  1. Model Metadata

    modelBuilder
      .HasAnnotation("ProductVersion", "7.0.7")
      .HasAnnotation("Relational:MaxIdentifierLength", 128);
    SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
    
  2. Entity Configuration
    For each entity, EF configures:

    • Properties (b.Property<type>("Name"))
    • Keys (b.HasKey("PK_Name"))
    • Indices (b.HasIndex("Field"))
    • Table & Schema (b.ToTable("Name", "irby"))
    • Inheritance (TPH via .HasDiscriminator())
  3. Relationships
    Defined via:

    b.HasOne("Namespace.Class", "Navigation")
     .WithMany("Collection")
     .HasForeignKey("ForeignKeyField")
     .OnDelete(DeleteBehavior.Cascade);
    

🚧 Warning: Large migrations can be memory-intensive. Consider breaking them into smaller logical steps when possible.


📂 Domain Entities & Data Models

Below is a high‐level grouping of entities defined in the model:

Asset Entities

Entity Table Schema Notes
Asset Asset irby Base class (TPH)
Computer Asset irby Inherits Asset, has OperatingSystemId
DeskPhone Asset irby Inherits Asset
Dock Asset irby Inherits Asset
MobileDevice Asset irby Unique Imei, custom column mapping
Monitor Asset irby Inherits Asset
NetworkEquipment Asset irby Inherits Asset
OfficePrinter Asset irby Adds Company, ContractEndDate
Printer Asset irby Inherits Asset
SafetyEquipment Asset irby Similar to Computer, TPH discriminator

Document & Blob Entities

Entity Table Schema Notes
BlobData BlobData irby Stores binary/image data
TempDocumentData TempDocumentData irby Staging area
DocumentImage DocumentImage irby Full document & OCR fields
DocumentAttribute DocumentAttribute irby Metadata attribute listing
DocumentCategory DocumentCategory irby Document grouping
DocumentType DocumentType irby Type definitions
IPMMigration IPMMigration irby Legacy migration staging
IrbyForms IrbyForms irby Custom forms storage

Employee, Job & Office Entities

Entity Table Schema Notes
Employee Employee irby Unique JdeNumber, CurrentJob
ODSEmployee ODS_Employee_Staging irby Staging table, alternate key
Job Job irby Unique JdeNumber
ODSJob ODS_Jobs_Staging irby Staging
FieldOffice FieldOffice irby Managers & superintendents
Customer Customer irby Basic customer lookup

Billing & Financial Entities

Entity Table Schema Notes
BillingInvoice BillingInvoice irby Invoice header data
CarrierType CarrierType irby Shipping carriers
CarrierTypeDetail CarrierTypeDetail irby Carrier sub‐types
GeneralLedger GeneralLedger irby GL accounts
GLTypeDetail GLTypeDetail irby GL sub‐accounts

Ticketing & Issue Entities

Entity Table Schema Notes
Ticket Ticket irby Service/help desk
Update Update irby Ticket history
Issue Issue irby Reference issues table

Time Tracking Entities

Entity Table Schema Notes
TimeEntryType TimeEntryType irby Lookup table
TimeSheetEntry TimeSheetEntry irby Daily hours worked

Miscellaneous Entities

Entity Table Schema Notes
CovidTestData CovidTestData irby COVID testing staging
LytxTemplate LytxTemplate irby Telematics data
Manufacturer AssetManufacturer irby Asset makes lookup
OperatingSystem OperatingSystem irby OS reference for computers
RequestOption RequestOption irby Support request items
State State irby US states
Vehicle Vehicle irby Fleet vehicles
AssetHistory AssetHistory irby Asset action audit trail
AssetModel AssetModel irby Asset model master
AssetModelDetail AssetModelDetail irby Asset model options

📈 Entity Relationship Diagram (UML)

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

    Asset o-- FieldOffice          : FieldOfficeId
    Asset o-- AssetModel          : ModelId
    Asset o-- Employee            : OwnerId

    Computer o-- OperatingSystem  : OperatingSystemId
    SafetyEquipment o-- OperatingSystem : OperatingSystemId

    Employee o-- Job              : CurrentJobId
    ODSEmployee o-- ODSJob        : ORG_BU

    Ticket o-- Update             : TicketId
    AssetModel o-- Manufacturer   : MakeId
    GLTypeDetail o-- GeneralLedger: GeneralLedgerId

🔗 Dependencies & Technologies

  • .NET Target Framework: .NET 7.0
  • Entity Framework Core: 7.0.7
  • Database Provider: Microsoft.EntityFrameworkCore.SqlServer
  • Tools:
    • dotnet ef CLI
    • Visual Studio / VS Code

⚙️ Usage & Examples

Applying the Migration

# Apply all pending migrations
dotnet ef database update

Rolling Back

# Roll back to the previous migration
dotnet ef database update 20230701120000_PreviousMigration

Inspecting Model

You can view the generated model snapshot under:

IrbyImaging.DbContext/Migrations/20230711141837_RemoveHrColumns.Designer.cs

✅ Best Practices

  • Keep Migrations Small & Focused
    Group related schema changes into separate migrations (e.g., one for column removals, another for table additions).
  • Review Before Commit
    Even though designer files are auto-generated, verify that your intended columns/tables are created or dropped.
  • Use Descriptive Migration Names
    RemoveHrColumns clearly states intent. Alternatives: AddInvoiceTable, RenameCustomerName.
  • Backup Production DB before applying migrations in critical environments.

🎯 Conclusion

This Designer file is a snapshot of your domain model after the RemoveHrColumns migration. It contains:

  • Definitions for ~60 entities
  • All keys, indices, table mappings, and TPH inheritance
  • Relationship wiring for navigations and cascade rules

Use it to reliably synchronize your EF Core model with the SQL Server database. Happy coding! 🚀


Generated with ❤️ by your EF Core Migrations system.