π 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
- π Overview & Purpose
- π§ Dependencies & Technologies
- π Key Functional Area
- π Data Models & Entities
- βοΈ Fluent API Configuration & Relationships
- π‘ How EF Core Migrations Work
- π¦ Usage Examples
- πΌ UML Diagram (Mermaid)
- β 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_UpdateColumnTypeOnPayrollFringeis 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
-
Add Migration
dotnet ef migrations add UpdateColumnTypeOnPayrollFringe- Generates two files:
20250303183151_UpdateColumnTypeOnPayrollFringe.cs(Up/Downlogic)20250303183151_UpdateColumnTypeOnPayrollFringe.Designer.cs(model snapshot)
- Generates two files:
-
Apply to Database
dotnet ef database update -
Inspect Snapshot
- The
.Designer.csfile is your model snapshot post-migration.
- The
π¦ 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 updateto apply changes. - Commit migration files to source control to keep schema in sync.
- Review accompanying
Enjoy your robust, EF-powered data access layer! π