πŸ“š Documentation: 20250303183151_UpdateColumnTypeOnPayrollFringe.Designer.cs

Welcome to the in-depth documentation of the Entity Framework Core migration snapshot UpdateColumnTypeOnPayrollFringe.Designer.cs. This file is auto-generated and represents the target model of your database schema after applying the migration named UpdateColumnTypeOnPayrollFringe.

Note: You generally should not edit this file manually; it is maintained by the EF Core tools.


πŸ—‚ Table of Contents

  1. πŸš€ Overview & Purpose
  2. πŸ”§ Dependencies & Technologies
  3. πŸ›  Key Functional Area
  4. πŸ—„ Data Models & Entities
  5. βš™οΈ Fluent API Configuration & Relationships
  6. πŸ’‘ How EF Core Migrations Work
  7. πŸ“¦ Usage Examples
  8. πŸ–Ό UML Diagram (Mermaid)
  9. βœ… Conclusion

πŸš€ Overview & Purpose

The UpdateColumnTypeOnPayrollFringe.Designer.cs file contains the BuildTargetModel(ModelBuilder modelBuilder) method, which:

  • Defines all entities, their properties, keys and indexes.
  • Specifies column types, max lengths, and relational configuration.
  • Represents the state of the EF Core model after the migration 20250303183151_UpdateColumnTypeOnPayrollFringe is applied.

This snapshot is used by EF Core to compute schema diffs and generate Up()/Down() methods in the accompanying migration class.


πŸ”§ Dependencies & Technologies

Technology Version/Notes
.NET Runtime .NET 7+ (C# 11)
Entity Framework Core 9.0.0 (as annotated in the model snapshot)
Database Provider Microsoft SQL Server (UseIdentityColumns extension)
Tools dotnet ef migrations, Visual Studio / VSCode tooling

πŸ›  Key Functional Area

[DbContext(typeof(IrbyContext))]
[Migration("20250303183151_UpdateColumnTypeOnPayrollFringe")]
partial class UpdateColumnTypeOnPayrollFringe
{
    protected override void BuildTargetModel(ModelBuilder modelBuilder)
    {
        // 1. Global annotations
        modelBuilder
            .HasAnnotation("ProductVersion", "9.0.0")
            .HasAnnotation("Relational:MaxIdentifierLength", 128);

        // 2. Identity column defaults for SQL Server
        SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

        // 3. Entities definitions...
        modelBuilder.Entity("IrbyImaging.DomainClasses.PayrollFringe", b => {
            // ...property configurations...
        });

        // 4. Relationships, indexes, table mappings...
    }
}
  • Global Annotations: specify EF Core version & SQL Server identifier length.
  • UseIdentityColumns: configures identity columns (auto-increment) for SQL Server.
  • Entity Configurations: each modelBuilder.Entity(...) block maps a CLR class to a table, columns, types & constraints.

πŸ—„ Data Models & Entities

The migration snapshot contains configurations for 80+ entities. For brevity, we highlight the PayrollFringe entityβ€”since the migration name suggests updates thereβ€”and provide a summary of a few additional entities.

PayrollFringe Entity (Focus)

The PayrollFringe table resides in schema irby and has had its column types updated (e.g., decimal precision, type mapping):

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

    b.HasKey("Id");
    b.Property<Guid>("Id")
        .ValueGeneratedOnAdd()
        .HasColumnType("uniqueidentifier");

    b.Property<decimal>("ActualHrsWorkedForWeek")
        .HasColumnType("decimal(18,2)");
    b.Property<decimal>("Annual401KValue")
        .HasColumnType("decimal(18,2)");
    b.Property<decimal>("AnnualizedFringe")
        .HasColumnType("decimal(18,2)");
    // ... other properties with decimal(18,2) ...
    b.Property<DateTime>("SelectedDate")
        .HasColumnType("datetime2");
    b.Property<string>("EmployeeName")
        .HasColumnType("nvarchar(max)");

    // Index on EmployeeId for fast lookups
    b.HasIndex("EmployeeId");
});

Key Columns

Column CLR Type SQL Type Notes
Id Guid uniqueidentifier Primary Key, auto-generated
EmployeeId Guid uniqueidentifier Foreign Key β†’ Employee
ActualHrsWorkedForWeek decimal decimal(18,2) Precision updated
Annual401KValue decimal decimal(18,2) Precision updated
ModifiedDate / AddedDate DateTime datetime2 Timestamps
EmployeeName, AddedBy, etc. string nvarchar(max) Unlimited length text fields

Selected Entity Summary Table

Entity Name Table (Schema) RowKey Notable Configurations
AccountBalances AccountBalances (irby) AccountBalanceId PK decimal(18,2) for costs & hours
Asset Asset (irby) Id PK TPH with Discriminator; nvarchar(21) Discriminator
Employee Employee (irby) EmployeeId PK Unique index on JdeNumber
Job Job (irby) JobId PK Unique index on JdeNumber
PayrollFringe PayrollFringe (irby) Id PK Updated decimal precision
WorkOrder WorkOrder (irby) WorkOrderId PK FK β†’ Job

βš™οΈ Fluent API Configuration & Relationships

  • Keys & Indexes: b.HasKey(...), b.HasIndex(...).
  • Column Types: .HasColumnType("decimal(18,2)"), .HasColumnType("nvarchar(max)"), .HasColumnType("datetime2").
  • Table/Schema: .ToTable("EntityName", "irby").
  • One-to-Many & Many-to-One:
    modelBuilder.Entity("PayrollFringe", b =>
        b.HasOne("Employee", "PayrollEmployee")
         .WithMany()
         .HasForeignKey("EmployeeId")
         .OnDelete(DeleteBehavior.Cascade)
         .IsRequired()
    );
    
  • TPH Inheritance (Asset): Discriminator column .HasDiscriminator(), mapping derived types (Computer, DeskPhone, MobileDevice, etc.) into the same table.

πŸ’‘ How EF Core Migrations Work

  1. Add Migration

    dotnet ef migrations add UpdateColumnTypeOnPayrollFringe
    
    • Generates two files:
      • 20250303183151_UpdateColumnTypeOnPayrollFringe.cs (Up/Down logic)
      • 20250303183151_UpdateColumnTypeOnPayrollFringe.Designer.cs (model snapshot)
  2. Apply to Database

    dotnet ef database update
    
  3. Inspect Snapshot

    • The .Designer.cs file is your model snapshot post-migration.

πŸ“¦ Usage Examples

1. Generating the Migration

cd IrbyImaging.DbContext
dotnet ef migrations add UpdateColumnTypeOnPayrollFringe

2. Reviewing the Model Snapshot

Open Migrations/20250303183151_UpdateColumnTypeOnPayrollFringe.Designer.cs to confirm:

  • Entities reflect your domain classes.
  • Column types (e.g., decimal precision) are as expected.

3. Updating the Database

dotnet ef database update

πŸ–Ό UML Diagram (Mermaid)

Below is a simplified UML class diagram showing Employee ↔ PayrollFringe relationship:

classDiagram
    class Employee {
        +Guid EmployeeId
        +string FirstName
        +string LastName
        +string Email
        // ...other properties...
    }

    class PayrollFringe {
        +Guid Id
        +Guid EmployeeId
        +decimal ActualHrsWorkedForWeek
        +decimal AnnualizedFringe
        +DateTime SelectedDate
        // ...other fringe properties...
    }

    Employee "1" <-- "0..*" PayrollFringe : has fringes

βœ… Conclusion

  • Purpose: The automatically generated snapshot ensures EF Core can track model changes and generate accurate migration scripts.
  • Key Focus: PayrollFringe’s updated column types (e.g., decimal(18,2)) reflect your schema design.
  • Next Steps:
    • Review accompanying Up()/Down() methods in the migration file.
    • Run dotnet ef database update to apply changes.
    • Commit migration files to source control to keep schema in sync.

Enjoy your robust, EF-powered data access layer! πŸš€