ποΈ Table of Contents
- Introduction
- Migration Overview & Purpose
- Key Functional Areas
- BuildTargetModel Method
- Data Models & Entity Mappings
- Relationships & UML Diagram
- Dependencies & Technologies
- Usage Example
- Conclusion
Introduction
Welcome to the FieldLogTimesheet migration designer documentation! π This file, FieldLogTimesheet.Designer.cs, is an auto-generated snapshot of your Entity Framework Core model at the time of the 20250115153413_FieldLogTimesheet migration. It is part of the IrbyImaging.DbContext.Migrations namespace and captures the state of all your domain entities and their mappings to the SQL Server database.
Migration Overview & Purpose
Migration Name: 20250115153413_FieldLogTimesheet
Designer File: FieldLogTimesheet.Designer.cs
DbContext: IrbyContext
This designer file is not where you define Up/Down operations. Instead, its purpose is to provide EF Core with a model snapshot so that future migrations can compute differences. It ensures consistency and helps EF track schema changes over time.
Key Functional Areas
-
ποΈ Model Snapshot
Captures the complete EF Core model at this migration. -
π¨ Entity Configurations
Defines entity properties, column types, primary keys, indexes, and discriminator mappings for table-per-hierarchy (TPH). -
π Relationships
Configures foreign key relationships and navigation properties. -
βοΈ SQL Server Extensions
Applies identity column conventions and relational annotations.
BuildTargetModel Method
[DbContext(typeof(IrbyContext))]
[Migration("20250115153413_FieldLogTimesheet")]
partial class FieldLogTimesheet
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// Suppress obsolete warnings
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
// SQL Server Identity columns by default
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// ... Entity definitions follow ...
#pragma warning restore 612, 618
}
}
- Annotations
ProductVersion: EF Core version (7.0.7).Relational:MaxIdentifierLength: Max length for SQL identifiers (128).
- UseIdentityColumns
Enables default identity (auto-increment) for integer PKs.
Data Models & Entity Mappings
The designer file defines 100+ domain entities. Below we focus on the FieldTimesheet feature and its closely related tables.
5.1 FieldTimesheet & Related Entities
| Entity | Table Schema | Description |
|---|---|---|
| FieldTimesheet | irby.FieldTimesheet |
Captures a daily field crew sheet. |
| EmployeeTimesheet | irby.EmployeeTimesheet |
Links employees to a field timesheet. |
| EquipmentTimesheet | irby.EquipmentTimesheet |
Links equipment to a field timesheet. |
| WorkEntry | irby.WorkEntry |
Records per-employee work details. |
| EquipmentEntry | irby.EquipmentEntry |
Records per-equipment usage details. |
5.2 Sample Entity: FieldTimesheet
modelBuilder.Entity("IrbyImaging.DomainClasses.FieldTimesheet", b =>
{
b.Property<Guid>("TimesheetId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("CrewId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ForemanSignature")
.HasColumnType("nvarchar(max)");
b.HasKey("TimesheetId");
b.ToTable("FieldTimesheet", "irby");
});
- Primary Key:
TimesheetId(GUID) - Columns:
CreatedDate: Timestamp when sheet was created.CrewId: Identifier for the crew (required).ForemanSignature: Signature or initials.
5.3 Sample Entity: WorkEntry
modelBuilder.Entity("IrbyImaging.DomainClasses.WorkEntry", b =>
{
b.Property<Guid>("WorkEntryId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmployeeTimesheetId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("WorkDate")
.HasColumnType("datetime2");
b.Property<double>("RegularHours")
.HasColumnType("float");
b.Property<double>("OvertimeHours")
.HasColumnType("float");
b.Property<bool>("Lunch")
.HasColumnType("bit");
// ... other per diem flags ...
b.HasIndex("EmployeeTimesheetId");
b.HasKey("WorkEntryId");
b.ToTable("WorkEntry", "irby");
});
- Foreign Key:
EmployeeTimesheetIdβEmployeeTimesheet.EmployeeTimesheetId - Business Data:
- Hours, meals, per diem, cost codes, etc.
Relationships & UML Diagram
Below is a simplified Entity-Relationship (ER) diagram for the Timesheet domain:
+-----------------+ 1 * +-----------------------+
| FieldTimesheet |---------------------->| EmployeeTimesheet |
|-----------------| +-----------------------+
| * TimesheetId | | * EmployeeTimesheetId |
| CreatedDate | | EmployeeId |
| CrewId | | TimesheetId |
+-----------------+ +-------------+---------+
1 *
+-------------+
|
v
+-----------------+
| WorkEntry |
+-----------------+
| * WorkEntryId |
| WorkDate |
| RegularHours |
+-----------------+
+-----------------+ 1 * +--------------------------+
| FieldTimesheet |---------------------->| EquipmentTimesheet |
+-----------------+ +--------------------------+
1 *
+-------------+
|
v
+----------------------+
| EquipmentEntry |
+----------------------+
| * EquipmentEntryId |
| WorkedHours |
+----------------------+
Dependencies & Technologies
- .NET 7.0 π―
- Entity Framework Core 7.0.7
- Microsoft.EntityFrameworkCore.SqlServer
- C# 11
- SQL Server (identity columns)
No thirdβparty integrations or external APIs are directly referenced in this designer file.
Usage Example
Generating & Applying the Migration
- Add Migration
dotnet ef migrations add FieldLogTimesheet \ --context IrbyContext \ --output-dir Migrations - Update Database
dotnet ef database update --context IrbyContext - Inspect Changes
- The designer snapshot (
*.Designer.cs) ensures EF Core knows the current model. - The migration file (
*.cs) in the same folder contains the Up() and Down() methods.
- The designer snapshot (
Querying Field Timesheets
using var ctx = new IrbyContext();
var todaySheets = ctx.FieldTimesheets
.Include(ft => ft.EmployeeTimesheets)
.ThenInclude(et => et.WorkEntries)
.Where(ft => ft.CreatedDate.Date == DateTime.Today)
.ToList();
Conclusion
The FieldLogTimesheet.Designer.cs file is a comprehensive model snapshot that EF Core uses internally to manage and compare schema changes. It:
- π Defines all domain entities and their column mappings.
- π Configures foreign keys, indexes, and discriminator strategies.
- βοΈ Applies SQL Server conventions for identity columns.
By understanding this file, you gain insight into how your Irb yImaging domain model translates into a relational schema and how EF Core tracks migrations over time. Happy coding! π