📄 Documentation for 20230822161843_AddSignInDateColumnsToAuditTable.Designer.cs


📑 Index

  1. 🔍 Overview & Purpose
  2. ⚙️ Dependencies & Technologies
  3. 🚀 Migration Metadata
  4. 🏗️ Model Snapshot
    4.1. Domain Entities Overview
    4.2. Asset Management Entities
    4.3. Audit Logging Entities
    4.4. Document Management Entities
    4.5. HR & Employee Entities
    4.6. Financial & Billing Entities
    4.7. Integration & Migration Entities
    4.8. Support & Ticketing Entities
  5. ✏️ AuditDetail Entity Changes
  6. 💡 Code Snippets
  7. 🖥️ UML Diagram for AuditDetail
  8. 📦 Applying This Migration
  9. 🎯 Conclusion

🔍 Overview & Purpose

This file is an auto-generated EF Core Designer snapshot for the migration:

AddSignInDateColumnsToAuditTable (timestamp: 20230822161843).

  • It lives in the IrbyImaging.DbContext.Migrations namespace.
  • Purpose: Capture the entire EF model after this migration has been applied.
  • Primary Change: Addition of new sign‑in tracking columns to the AuditDetail table.

✨ Every time you scaffold a migration in EF Core, a .Designer.cs file is produced to represent the target model—this is that file.


⚙️ Dependencies & Technologies

  • Language: C#
  • ORM: Entity Framework Core (v7.0.7)
  • Database Provider: Microsoft SQL Server
  • Schema: using "irby" as the default schema for most tables.
  • Key Concepts:
    • Model snapshots
    • Migrations (Up/Down methods not shown here)
    • TPH (Table‑Per‑Hierarchy) mapping for polymorphic Asset entities
    • Fluent API configuration (ModelBuilder)

🚀 Migration Metadata

Attribute Value
[DbContext(typeof(IrbyContext))] Indicates this migration targets IrbyContext
[Migration("20230822161843_AddSignInDateColumnsToAuditTable")] Unique identifier + name
Designer Class partial class AddSignInDateColumnsToAuditTable
Core Method protected override void BuildTargetModel(ModelBuilder modelBuilder)
// Designer-generated snapshot of the EF model after this migration
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
    modelBuilder
        .HasAnnotation("ProductVersion", "7.0.7")
        .HasAnnotation("Relational:MaxIdentifierLength", 128);

    SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

    // … hundreds of entity configurations follow …
}

🏗️ Model Snapshot

The BuildTargetModel method configures every entity in your domain. Below is a high‑level grouping of the main areas with the key entities in each.

Domain Entities Overview

Domain Area Key Entities
Asset Management 🚗 Asset, AssetHistory, AssetModel, AssetModelDetail
Audit Logging 📝 AuditDetail
Billing & Invoicing 💰 BillingInvoice
Document Storage 📁 BlobData, DocumentAttribute, DocumentCategory, DocumentImage, DocumentType, TempDocumentData
HR & Employees 👥 Employee, Department, Role, Permissions, LinkRolePermission, LinkUserRole, TimeEntryType, TimeSheetEntry
Jobs & Offices 🏢 Job, FieldOffice
Financial 📊 GeneralLedger, GLTypeDetail
Integration & Migration 🔄 IPMMigration, IrbyForms, ODSCustomer, ODSEmployee, ODSJob
Support & Ticketing 🎟 Ticket, Update, Issue
Miscellaneous Manufacturer, OperatingSystem, RequestOption, State, Vehicle, LytxTemplate, CovidTestData, Customer

Asset Management Entities

Entity Name Table (Schema) Comments
Asset irby.Asset Base class using TPH for various asset types
AssetHistory irby.AssetHistory Audit trail for asset state changes
AssetModel irby.AssetModel References a Manufacturer (1‑to‑many)
AssetModelDetail AssetModelDetail Extra metadata per model

Audit Logging Entities

Entity Name Table (Schema) Purpose
AuditDetail irby.AuditDetail Captures user actions, controller, page, login status

Focus: This is the table modified by the migration.


Document Management Entities

Entity Name Table (Schema) Description
BlobData irby.BlobData Raw binary data storage
DocumentAttribute irby.DocumentAttribute Custom attribute definitions for docs
DocumentCategory irby.DocumentCategory Category metadata
DocumentImage irby.DocumentImage Stores images + OCR + index tags
DocumentType irby.DocumentType Classification of docs
TempDocumentData irby.TempDocumentData Staging table for batch imports

HR & Employee Entities

Entity Name Table (Schema) Relationship Highlights
Employee irby.Employee FK → Department, Job, Role
Department irby.Department Groups employees
Role irby.Role Security roles
Permissions irby.Permissions Available permissions
LinkRolePermission irby.LinkRolePermission M:N Role ↔ Permission
LinkUserRole irby.LinkUserRole M:N Employee ↔ Role
TimeEntryType irby.TimeEntryType Types of time (e.g., Overtime, Standard)
TimeSheetEntry irby.TimeSheetEntry FK → Employee, TimeEntryType

Financial & Billing Entities

Entity Name Table (Schema) Details
GeneralLedger irby.GeneralLedger Chart‐of‐accounts
GLTypeDetail GLTypeDetail Subcategories under a GL account
BillingInvoice irby.BillingInvoice Invoices charged to carriers/customers

Integration & Migration Entities

Entity Name Table (Schema) Purpose
IPMMigration irby.IPMMigration Legacy import of images
IrbyForms irby.IrbyForms Standardized IRBY form templates
ODSCustomer ODSCustomers Read‐only view of external customer system (ODS)
ODSEmployee ODSEmployees Read‐only view of external HR system (ODS)
ODSJob ODSJobs Read‐only view of external job system (ODS)

Support & Ticketing Entities

Entity Name Table (Schema) Role
Ticket irby.Ticket IT & support request tracking
Update irby.Update Comments/Status changes for a Ticket
Issue irby.Issue Enumeration of recurring issues

✏️ AuditDetail Entity Changes

🎯 This migration’s primary goal is to add sign‑in tracking columns to the AuditDetail table.

Column Name SQL Type Nullable Description
LastSignInDateTime datetime2 Yes Timestamp of the user’s last interactive login
LastNonInteractiveSignInDateTime datetime2 Yes Timestamp of the user’s last non‑interactive sign‑in (token refresh)
IsFirstLogin nvarchar(max) Yes Flag indicating if this was the first login of the session
LangId nvarchar(max) Yes Locale/language code for the session
LoginStatus nvarchar(max) Yes Status of login (e.g., Success, Failure, LockedOut)

💡 While the Designer snapshot shows all current columns, this migration specifically adds the two DateTime? fields above. The string flags were likely introduced together or in subsequent migrations.


💡 Code Snippets

1) Designer Snapshot for AuditDetail

modelBuilder.Entity("IrbyImaging.DomainClasses.AuditDetail", b =>
{
    b.HasKey("AuditDetailId");
    b.ToTable("AuditDetail", "irby");

    b.Property<Guid>("AuditDetailId")
     .HasColumnType("uniqueidentifier");

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

    b.Property<DateTime>("ActivityDate")
     .HasColumnType("datetime2");

    // … existing props …

    // 👇 Newly added in this migration:
    b.Property<string>("IsFirstLogin")
     .HasColumnType("nvarchar(max)");

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

    b.Property<DateTime?>("LastNonInteractiveSignInDateTime")
     .HasColumnType("datetime2");

    b.Property<DateTime?>("LastSignInDateTime")
     .HasColumnType("datetime2");

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

    // Relationships:
    b.HasIndex("EmployeeId");
    b.HasIndex("RoleId");
    b.HasOne("IrbyImaging.DomainClasses.Employee", "User")
     .WithMany()
     .HasForeignKey("EmployeeId");
    b.HasOne("IrbyImaging.DomainClasses.Role", "Role")
     .WithMany()
     .HasForeignKey("RoleId");
});

2) Typical Up/Down Migration (in the .cs file)

public partial class AddSignInDateColumnsToAuditTable : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.AddColumn<DateTime?>(
            name: "LastSignInDateTime",
            schema: "irby",
            table: "AuditDetail",
            type: "datetime2",
            nullable: true);

        migrationBuilder.AddColumn<DateTime?>(
            name: "LastNonInteractiveSignInDateTime",
            schema: "irby",
            table: "AuditDetail",
            type: "datetime2",
            nullable: true);

        // … (string flags if part of this migration) …
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropColumn(
            name: "LastSignInDateTime",
            schema: "irby",
            table: "AuditDetail");

        migrationBuilder.DropColumn(
            name: "LastNonInteractiveSignInDateTime",
            schema: "irby",
            table: "AuditDetail");
    }
}

🖥️ UML Diagram for AuditDetail

@startuml
class AuditDetail {
    + Guid    AuditDetailId
    + string  ActionName
    + DateTime ActivityDate
    + string  Area
    + string  ControllerName
    + string  PageAccessed
    + string  UrlReferrer
    + string  SessionId
    + string  IpAddress
    + Guid    UserId
    + Guid?   RoleId
    + Guid?   EmployeeId
    + string  LoginStatus
    + string  IsFirstLogin
    + string  LangId
    + DateTime? LastSignInDateTime
    + DateTime? LastNonInteractiveSignInDateTime
}
@enduml

🔍 This UML focuses on the properties of AuditDetail, highlighting the new sign‑in tracking fields.


📦 Applying This Migration

  1. Scaffold (already done):
    dotnet ef migrations add AddSignInDateColumnsToAuditTable
    
  2. Update database:
    dotnet ef database update
    
  3. Verify:
    SELECT TOP 10 
      AuditDetailId,
      LastSignInDateTime,
      LastNonInteractiveSignInDateTime
    FROM irby.AuditDetail;
    

🎯 Conclusion

This Designer file is an essential EF Core model snapshot that ensures migrations know the precise shape of your data model after applying AddSignInDateColumnsToAuditTable. In particular:

  • ✅ New sign‑in tracking fields are added to AuditDetail for both interactive and non‑interactive scenarios.
  • 🔗 All entities, relationships, indices, and table mappings are fully described in BuildTargetModel.
  • 🚀 Use standard EF Core commands to apply this change to your SQL Server database.

Happy coding! 🚀