📄 Documentation: 20240701194731_AddMechanicTimesheet.Designer.cs
Auto-generated Entity Framework Core migration snapshot for the “AddMechanicTimesheet” migration.
This file captures the complete EF Core model snapshot at the point when the migration was created. It is not meant to be edited by hand, but serves as a source of truth for EF’s migration engine.
Table of Contents
- Overview & Purpose
- Migration Metadata
- BuildTargetModel Method
- Key Entity: MechanicTimesheet
- Model Snapshot Summary
- Relationships & Navigation
- Applying the Migration
- Dependencies & Technologies
- Third‑Party Integrations
- UML Diagram
- Conclusion
1. Overview & Purpose 🧭
This designer file is part of the IrbyImaging.DbContext project’s Migrations folder. It represents the model snapshot against which EF Core generates SQL to apply schema changes. In particular, the migration 20240701194731_AddMechanicTimesheet introduces a new MechanicTimesheet table to the database.
- Why it exists: EF Core uses this auto-generated code to track your DbContext’s model over time.
- When it runs: During
dotnet ef database updateorUpdate-Databasein Package Manager Console. - What it contains: A giant
BuildTargetModel(ModelBuilder modelBuilder)method defining every entity, property, relationship and table mapping in the context.
2. Migration Metadata 📑
[DbContext(typeof(IrbyContext))]
[Migration("20240701194731_AddMechanicTimesheet")]
partial class AddMechanicTimesheet
{
protected override void BuildTargetModel(ModelBuilder modelBuilder) { … }
}
- DbContext:
IrbyContext - Migration Id:
20240701194731_AddMechanicTimesheet - Designer: Holds the snapshot, while the sibling
AddMechanicTimesheet.cscontains the actualUp()/Down()methods.
3. BuildTargetModel Method 🔧
Inside BuildTargetModel, EF Core:
- Applies annotations:
ProductVersion: EFCore 7.0.7Relational:MaxIdentifierLength: 128
- Enables SQL Server identity columns via
UseIdentityColumns(). - Defines all entities (over 100 tables!).
- Configures each entity’s properties, keys, indexes, relationships and table-to-class mappings.
Note: This method is auto‑generated; manual edits will be overwritten by future migrations.
4. Key Entity: MechanicTimesheet ➕
4.1 Properties & Column Mapping
| Property | CLR Type | Column Name | Notes |
|---|---|---|---|
| Id | Guid |
Id |
PK, generated |
| CostType | string |
CostType |
nvarchar(max) |
| Description | string |
Description |
nvarchar(max) |
| EmployeeId | Guid |
EmployeeId |
FK to Employee |
| StartDate | DateTime |
StartDate |
datetime2 |
| StartTime | string |
StartTime |
nvarchar(max) |
| EndTime | string |
EndTime |
nvarchar(max) |
| RegularTime | string |
RegularTime |
nvarchar(max) |
| OverTime | string |
OverTime |
nvarchar(max) |
| PayCode | string |
PayCode |
nvarchar(max) |
| Job | string |
Job |
nvarchar(max) |
| WorkOrder | string |
WorkOrder |
nvarchar(max) |
| UnitNumber | string |
UnitNumber |
nvarchar(max) |
| SubmittedBy | string |
SubmittedBy |
nvarchar(max) |
| Status | int |
Status |
bitmapped enum? |
4.2 Table & Schema Mapping
modelBuilder.Entity("IrbyImaging.DomainClasses.MechanicTimesheet", b => {
b.Property<Guid>("Id").ValueGeneratedOnAdd().HasColumnType("uniqueidentifier");
// … other properties …
b.HasKey("Id");
b.ToTable("MechanicTimesheet", "irby");
});
- Schema:
irby - Table:
MechanicTimesheet
5. Model Snapshot Summary 📦
While this migration’s primary goal is adding MechanicTimesheet, the snapshot also re-declares the entire model:
- Domain Classes: Asset, AssetHistory, AssetModel, BlobData, CarrierType, ContractTypeDetails, CovidTestData, Customer, Department, DocumentImage, Employee, Equipment, FieldOffice, Job, PurchaseOrder, WorkOrder, Ticket, etc.
- View Models: None—this file only covers data models.
- Indexes & Constraints: Many unique and non-unique indexes (e.g.
JdeNumber), foreign keys, composite keys.
For brevity, only the new entity is documented in full. All other entities follow the same pattern of properties → column mapping → keys → table.
6. Relationships & Navigation 🏗️
-
MechanicTimesheet.Employee
- Navigation: not explicitly configured here, but
EmployeeIdcan be navigated via your domain class.
- Navigation: not explicitly configured here, but
-
Global: Each entity with
HasOne(...).WithMany(...)defines FKs and navigations. -
Example snippet for Asset–FieldOffice relation:
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => { b.HasOne("IrbyImaging.DomainClasses.FieldOffice", "FieldOffice") .WithMany("Assets") .HasForeignKey("FieldOfficeId"); });
7. Applying the Migration 🚀
# Using CLI
dotnet ef database update 20240701194731_AddMechanicTimesheet
# Using Package Manager Console
Update-Database -Migration 20240701194731_AddMechanicTimesheet
This will:
- Compare the model snapshot vs. the database.
- Generate SQL to create the
irby.MechanicTimesheettable (and any other delta). - Execute the SQL and update the
__EFMigrationsHistorytable.
8. Dependencies & Technologies 🛠️
- .NET 7.0
- Entity Framework Core 7.0.7
- Provider: Microsoft.EntityFrameworkCore.SqlServer
- Annotations:
UseIdentityColumns(),HasAnnotation("ProductVersion","7.0.7")
9. Third‑Party Integrations 🔌
- EntityFrameworkCore (ORM)
- SQL Server via Microsoft’s EFCore provider
- No other external libraries are referenced in this auto‑generated file.
10. UML Diagram 📈
Below is a simplified UML representing the new MechanicTimesheet entity and its relationship to Employee.
@startuml
package "irby" {
class MechanicTimesheet {
+ Guid Id
+ string CostType
+ DateTime StartDate
+ string StartTime
+ string EndTime
+ string RegularTime
+ string OverTime
+ string PayCode
+ string Job
+ string WorkOrder
+ string UnitNumber
+ string SubmittedBy
+ int Status
}
class Employee {
+ Guid EmployeeId
+ string FirstName
+ string LastName
-- other properties --
}
MechanicTimesheet "1" --> "1" Employee : EmployeeId
}
@enduml
11. Conclusion 🏁
AddMechanicTimesheet.Designer.csis an auto‑generated snapshot capturing the entire EF Core model at migration20240701194731.- Its primary purpose is to enable EF Core to compute schema diffs and generate SQL.
- Developers should not edit this file manually—use standard EF migration commands to keep it in sync.
- The new
MechanicTimesheettable is now part of the model, with all properties, keys and mappings clearly defined.
Happy coding! 🚗🔧