📚 Documentation: 20220427163827_HelpDeskCreate.Designer.cs


Table of Contents

  1. 📖 Overview & Purpose
  2. 🛠️ Dependencies & Technologies
  3. 🔑 Key Functional Areas
  4. 🏷️ Entities & Data Models
  5. 🔗 Relationships & Navigation
  6. 📊 Database Schema Mapping
  7. 🖼️ UML Diagram (Mermaid)
  8. 🚀 Usage & Migration Workflow
  9. 📝 Conclusion

📖 Overview & Purpose

This file is the auto-generated migration designer for the HelpDeskCreate migration in the IrbyImaging.DbContext assembly. It:

  • Implements the BuildTargetModel(ModelBuilder modelBuilder) method.
  • Describes the complete EF Core model snapshot after applying the 20220427163827_HelpDeskCreate migration.
  • Is used by EF Core tooling to generate SQL scripts or apply schema changes to the database.

Note: This is not handwritten code; any manual edits will be lost on the next scaffold.


🛠️ Dependencies & Technologies

Component Version/Details
.NET 5.0.12
Entity Framework Core Microsoft.EntityFrameworkCore (v5.0.12)
SQL Server Provider Microsoft.EntityFrameworkCore.SqlServer
Target Database Microsoft SQL Server (Identity columns)

Under the covers, the file uses

  • Fluent API to configure entities
  • Value Conversions and Relational Annotations
  • Discriminators for inheritance mapping

🔑 Key Functional Areas

  1. Model Annotations

    • Identifier length, product version, identity strategy:
      modelBuilder
        .HasAnnotation("Relational:MaxIdentifierLength", 128)
        .HasAnnotation("ProductVersion", "5.0.12")
        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
      
  2. Entity Configuration

    • Defines properties (Property<T>()), keys (HasKey()), indices (HasIndex()), tables (ToTable()), and discriminators (HasDiscriminator()).
  3. Inheritance Mapping

    • Single-table inheritance for different Asset subtypes (Computer, MobileDevice, etc.) using a Discriminator column.
  4. Relationships & Navigation

    • Specifies one-to-many and many-to-one relationships via HasOne(), WithMany(), and HasForeignKey().

🏷️ Entities & Data Models

Below is a selection of core entities configured in this migration:

Entity Class Table Name Schema Key Type
Asset Asset irby Guid
AssetModel AssetModel irby int
Computer (inherits Asset) Asset irby Guid
MobileDevice (inherits Asset) Asset irby Guid
Employee Employee irby Guid
FieldOffice FieldOffice irby Guid
Ticket Ticket irby Guid
Update Update irby Guid
CovidTestData CovidTestData irby Guid
DocumentImage DocumentImage irby Guid

Tip: Use the full code block below in your IDE to explore all entities and see their properties.


🔗 Relationships & Navigation

  • Asset → FieldOffice (many-to-one)
  • Asset → AssetModel (many-to-one)
  • Asset → Employee (Owner) (many-to-one)
  • AssetModel → Manufacturer (many-to-one)
  • Employee → Job (many-to-one)
  • FieldOffice → Employee (Manager) (many-to-one)
  • Ticket → Update (one-to-many)
  • Computer/SafetyEquipment → OperatingSystem (many-to-one)

Each relationship is configured with cascade behaviors where specified.


📊 Database Schema Mapping

C# Property SQL Type Constraints
Guid Id uniqueidentifier Primary Key, ValueGeneratedOnAdd
string Category nvarchar(max) IsRequired()
DateTimeOffset PurchaseDate datetimeoffset
int ModelId int FK to AssetModel(Id)
int OperatingSystemId int FK to OperatingSystem(Id)
string Imei nvarchar(450) Unique Index
... ... ...

🖼️ UML Diagram (Mermaid)

classDiagram
    class Asset {
        <<Entity>>
        +Guid Id
        +string Category
        +DateTimeOffset PurchaseDate
        +string Status
    }
    class Computer {
        +string AssetNumber
        +string CpsNumber
        +string UnitNumber
    }
    class AssetModel {
        +int Id
        +string Name
        +string Category
    }
    class Manufacturer {
        +int Id
        +string Name
    }
    class Employee {
        +Guid Id
        +string FirstName
        +string LastName
    }
    class FieldOffice {
        +Guid Id
        +string Name
    }
    Asset <|-- Computer
    AssetModel --> Manufacturer
    Asset --> AssetModel
    Asset --> FieldOffice
    Asset --> Employee
    Employee --> FieldOffice : manages

🚀 Usage & Migration Workflow

  1. Scaffold the Migration
    dotnet ef migrations add HelpDeskCreate
    
  2. Review Generated Files
    • 20220427163827_HelpDeskCreate.cs
    • 20220427163827_HelpDeskCreate.Designer.cs (this file)
  3. Apply to Database
    dotnet ef database update HelpDeskCreate
    
  4. Inspect Database
    • Verify tables in the irby schema.
    • Check constraints, indices, and relationships.

Pro Tip: Always check the generated SQL script with:

dotnet ef migrations script HelpDeskCreate

📝 Conclusion

This designer file represents the complete EF Core model for the HelpDeskCreate migration. It ensures that every entity, property, and relationship is accurately captured for schema generation, database updates, and model consistency.

By understanding and referring to this documentation, developers can:

  • Quickly navigate the data model
  • Verify relationships and constraints
  • Debug issues related to migrations or schema drift

Happy coding! 🚀