📝 Table of Contents

  1. 📖 Overview & Purpose
  2. 🛠️ Key Functional Areas
  3. 📦 Dependencies & Technologies
  4. 🏷️ Data Models & Mappings
    4.1. Asset Domain
    4.2. Document Imaging Domain (Bidding)
    4.3. Employee & Security Domain
    4.4. Additional Domains (Billing, HR, etc.)
  5. 🔗 Relationships & Navigation Properties
  6. ⚙️ Identity, Keys & Indices
  7. 🧩 Inheritance & Discriminators
  8. 💻 Sample BuildTargetModel Snippets
  9. 🚀 How to Use This Migration
  10. 🏁 Conclusion

📖 Overview & Purpose

The AddBiddingImaging.Designer.cs file is an auto‑generated snapshot of the EF Core model used by the AddBiddingImaging migration in the IrbyImaging.DbContext. Its primary roles are:

  • 🎯 Capturing the target database schema after applying the migration.
  • 🔄 Defining entities, properties, indices, relationships, and inheritance strategies.
  • 🛡️ Ensuring EF Core can compare models for future migrations.

Note: You normally do not edit this file directly—it is regenerated whenever you scaffold a new migration.


🛠️ Key Functional Areas

  • Model Configuration: Uses ModelBuilder to configure every domain class.
  • Schema Mapping: Assigns tables to schemas (e.g., "irby").
  • Entity Inheritance: Implements Table‑Per‑Hierarchy (TPH) for assets.
  • Index & Key Setup: Defines primary keys (HasKey) and indices (HasIndex).
  • New Bidding‑Imaging Support:
    • Adds IsBidding flags.
    • Introduces BiddingDocumentType GUID on DocumentImage.

📦 Dependencies & Technologies

Technology Version Purpose
.NET / C# 7.0 Language & runtime
Microsoft.EntityFrameworkCore 7.0.7 ORM
Microsoft.EntityFrameworkCore.SqlServer 7.0.7 SQL Server provider
EF Core Migrations Built‑in Database change tracking

🏷️ Data Models & Mappings

Below is a high‑level look at some core domain entities configured in this migration.

4.1 Asset Domain

Entity Table (irby.Asset) Inheritance Key
Asset (base) Asset TPH → Discriminator Id : Guid
Computer Asset Discriminator = "Computer" Id
MobileDevice Asset Discriminator = "MobileDevice" Id
SafetyEquipment Asset Discriminator = "SafetyEquipment" Id
… … … …
  • Discriminator column (Discriminator) differentiates subtypes.
  • TPH Mapping: All asset types in one table with subtype columns.

4.2 Document Imaging Domain (Bidding)

Entity Table (irby.DocumentImage) New Fields
DocumentImage DocumentImage (schema irby) IsBidding : bool
BiddingDocumentType : Guid
TempDocumentData TempDocumentData (schema irby) IsBidding : bool
DocumentCategory DocumentCategory (schema irby) IsBidding : bool

These properties surface the state of bidding‑specific documents:

  • IsBidding: Marks that an image/document belongs to the bidding workflow.
  • BiddingDocumentType: Foreign key into DocumentType for categorizing bidding docs.

4.3 Employee & Security Domain

Entity Table (irby.Employee) Key Notes
Employee Employee EmployeeId : Guid Index on JdeNumber (unique).
Role Role RoleId : Guid —
Permissions Permissions PermissionId —
LinkUserRole LinkUserRole (irby) Composite FK Many‑to‑many between Employee↔Role
LinkRolePermission LinkRolePermission Composite FK Many‑to‑many between Role↔Permission

4.4 Additional Domains (Billing, HR, etc)

  • Billing: BillingInvoice table with charges & GL references.
  • HR: Timesheets (HRTimeSheet, HREmployeeTimeEntry, …).
  • FieldOffice & Job: Geographical & job‑site mappings.
  • Temporary Data: TempDocumentData, BlobData for staging images.

🔗 Relationships & Navigation Properties

  • One‐to‐Many

    • FieldOffice → Assets
    • Job → Employees
    • DocumentImage → AuditDetail via DocumentImageId
  • Many‐to‐Many (via linking tables)

    • Employee ↔ Role (LinkUserRole)
    • Role ↔ Permissions (LinkRolePermission)
  • Cascade Delete

    • Deleting a Job cascades to its Employees and PurchaseOrders.
    • Deleting a DocumentType (accounting/bidding/HR etc.) cascades to DocumentImage.
classDiagram
    Asset <|-- Computer
    Asset <|-- MobileDevice
    DocumentImage *-- DocumentType : BiddingDocumentType
    Role *-- Permissions : LinkRolePermission
    Employee *-- Role : LinkUserRole
    FieldOffice "1" o-- "*" Asset
    Job "1" o-- "*" Employee

⚙️ Identity, Keys & Indices

  • ValueGeneratedOnAdd
    • Default GUID or int identity for primary keys.
  • UseIdentityColumns
    • SQL Server identity strategy for numeric keys.
  • Indices
    • Uniqueness on business fields (e.g., Employee.JdeNumber, FieldOffice.JdeNumber).
    • Navigation FKs are indexed for performant joins.

🧩 Inheritance & Discriminators

  • Table‑Per‑Hierarchy (TPH) for the Asset hierarchy:
    modelBuilder.Entity<Asset>()
        .HasDiscriminator<string>("Discriminator")
        .HasValue<Asset>("Asset")
        .HasValue<Computer>("Computer")
        .HasValue<MobileDevice>("MobileDevice")
        .HasValue<SafetyEquipment>("SafetyEquipment");
    
  • Subtypes share one table and pick up extra columns when needed.

💻 Sample BuildTargetModel Snippets

protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
    modelBuilder
        .HasAnnotation("ProductVersion", "7.0.7")
        .HasAnnotation("Relational:MaxIdentifierLength", 128);

    SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

    // … Asset Definition
    modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b =>
    {
        b.Property<Guid>("Id").ValueGeneratedOnAdd();
        b.Property<string>("Category").IsRequired();
        b.Property<string>("Discriminator").IsRequired();
        b.HasKey("Id");
        b.HasIndex("FieldOfficeId");
        b.ToTable("Asset", "irby");
        b.HasDiscriminator<string>("Discriminator")
         .HasValue("Asset");
    });

    // … DocumentImage Bidding Support
    modelBuilder.Entity("IrbyImaging.DomainClasses.DocumentImage", b =>
    {
        b.Property<Guid>("DocumentImageId");
        b.Property<bool>("IsBidding");
        b.Property<Guid>("BiddingDocumentType");
        b.HasKey("DocumentImageId");
        b.ToTable("DocumentImage", "irby");
    });

    // … Temporary Staging
    modelBuilder.Entity("IrbyImaging.DomainClasses.TempDocumentData", b =>
    {
        b.Property<Guid>("TempDocumentDataId").ValueGeneratedOnAdd();
        b.Property<bool>("IsBidding");
        b.HasKey("TempDocumentDataId");
        b.ToTable("TempDocumentData", "irby");
    });

    // More entity configurations…
}

🚀 How to Use This Migration

  1. Scaffold a Migration
    dotnet ef migrations add AddBiddingImaging
    
  2. Review & Apply
    dotnet ef database update
    
  3. Verify Schema
    • Check irby.DocumentImage for the new IsBidding and BiddingDocumentType columns.
    • Confirm TempDocumentData.IsBidding and DocumentCategory.IsBidding exist.

🏁 Conclusion

This AddBiddingImaging.Designer.cs file represents the complete EF Core model snapshot after introducing bidding‑related imaging support. It:

  • Extends DocumentImage and TempDocumentData with IsBidding and a foreign key BiddingDocumentType.
  • Updates the DocumentCategory model to include IsBidding.
  • Showcases comprehensive entity configurations, relations, inheritance, and indices across the irby schema.

With this migration applied, the database schema is ready to capture and classify bidding documents alongside existing accounting, HR, and safety workflows. 🚀


🎉 Happy Coding! 🎉