📖 Documentation: 20240724175502_AddRejectionCommentMechanicTimesheet.Designer.cs
Module
IrbyImaging.DbContext/Migrations
Generated
July 24, 2024 – 17:55:02
Purpose
Snapshot of the EF Core model after theAddRejectionCommentMechanicTimesheetmigration.
🗂 Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- EF Core Migrations Anatomy
- Data Model Snapshot
- Relationships & Indexes
- How to Apply & Use This Migration
- Sample Code & CLI Commands
- UML Diagram (Mermaid)
- Conclusion
1. Overview & Purpose
The Designer file is an auto‑generated snapshot of your Entity Framework Core model after running the migration AddRejectionCommentMechanicTimesheet. It is not hand‑edited; EF Core uses it to understand how to transition from one model state to another.
- It contains the
BuildTargetModel(ModelBuilder modelBuilder)method, which defines:- Tables, columns, types, keys, indexes.
- Relationships (foreign keys, navigations).
- Inheritance via TPH (Table‑per‑Hierarchy).
- Key change: The
MechanicTimesheetentity now has a new column/property:b.Property<string>("RejectionComment") .HasColumnType("nvarchar(max)");
2. Key Functional Areas
- 🛠 Model Snapshot
Captures the entire domain model at this migration point. - 📑 Schema Definition
Maps CLR classes to tables, columns, data types, constraints. - 🔗 Relationships
Configures FK constraints and navigation properties. - 📊 Indexes & Keys
Ensures efficient lookups (e.g., unique indexes, composite keys). - 🌐 Inheritance
Implements TPH forAssetand its subtypes (Computer,MobileDevice, etc.).
3. Dependencies & Technologies
| Technology | Version/Notes |
|---|---|
| .NET / C# | 7.x / EF Core 7.0.7 |
| Microsoft.EntityFrameworkCore | Core ORM for mapping domain → relational |
| Microsoft.EntityFrameworkCore.SqlServer | SQL Server provider |
| EF Core Migrations | Tracks incremental Up() / Down() changes |
4. EF Core Migrations Anatomy
4.1. Migration Class vs. Designer File
-
Migration Class (
20240724175502_AddRejectionCommentMechanicTimesheet.cs)- Contains
Up()andDown()methods. - Adds/removes the
RejectionCommentcolumn in theMechanicTimesheettable.
- Contains
-
Designer File (
...Designer.cs)- Contains a full model snapshot via
BuildTargetModel. - EF Core uses this to compare before/ after states when scaffolding future migrations.
- Contains a full model snapshot via
4.2. BuildTargetModel Method
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// ... thousands of lines defining Entities, Properties, Keys, Indexes ...
}
-
Annotations:
.HasAnnotation("ProductVersion", "...")records EF Core version..UseIdentityColumns()configures identity PK by default.
-
Entity Definitions:
Each.Entity("Namespace.ClassName", b => { ... })block defines one table.
5. Data Model Snapshot
Note: Over 80 domain classes are configured. Below is a representative sample.
5.1. Global Annotations & Conventions
- Schema: Default schema is
"irby"for most tables. - Identifier Length: Max 128 chars for SQL identifiers.
- Identity: SQL Server identity columns for integer PKs.
5.2. Selected Entities & Tables
| Entity Class | Table Name | Schema | Key | Notes |
|---|---|---|---|---|
IrbyImaging.DomainClasses.Asset |
Asset |
irby | Id : uniqueidentifier |
Base for TPH inheritance. |
MechanicTimesheet |
MechanicTimesheet |
irby | Id : uniqueidentifier |
Focus entity. |
AssetModel |
AssetModel |
irby | Id : int |
Cascade FK to MakeId. |
Employee |
Employee |
irby | EmployeeId : uniqueidentifier |
Unique index on JdeNumber. |
WorkOrder |
WorkOrder |
irby | WorkOrderId : uniqueidentifier |
FK to Job. |
Job |
Job |
irby | JobId : uniqueidentifier |
Unique index on JdeNumber. |
| … 70+ more |
AssetHistoryBillingInvoiceCarrierType/CarrierTypeDetailCovidTestDataCustomer,Department,DirectorLeaseInfo,DirectorPropertiesDocumentAttribute,DocumentCategory,DocumentImage,DocumentTypeEquipment,EquipmentType,EquipmentClassFieldOffice,GeneralLedger,GLTypeDetailLinkRolePermission,LinkUserRole,Role,PermissionsPurchaseOrder,RequestOption,Ticket,UpdateTimeSheetEntry,TimeEntryType,WIP,WorkOrder, etc.
5.3. MechanicTimesheet: New RejectionComment
modelBuilder.Entity("IrbyImaging.DomainClasses.MechanicTimesheet", b =>
{
b.ToTable("MechanicTimesheet", "irby");
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
// ... other existing properties ...
b.Property<string>("RejectionComment") // <-- ADDED by this migration
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
});
- Before:
MechanicTimesheethad columns likeStartDate,EmployeeId,Status, etc. - After:
A free‑textRejectionCommentto capture supervisor feedback on rejected timesheets.
6. Relationships & Indexes
- Foreign Keys:
- E.g.
MechanicTimesheet→Employee(viaEmployeeId, cascades on delete?).
- E.g.
- Indexes:
- Many unique indexes on business keys (
JdeNumber,Imei, etc.). - Composite keys where needed.
- Many unique indexes on business keys (
Example:
b.HasIndex("EmployeeId"); b.HasIndex("TimeEntryTypeId"); b.HasOne("IrbyImaging.DomainClasses.Employee", "Employee") .WithMany() .HasForeignKey("EmployeeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired();
7. How to Apply & Use This Migration
- Add Migration
dotnet ef migrations add AddRejectionCommentMechanicTimesheet - Review/Customize
- Check the generated
Up()andDown()in
20240724175502_AddRejectionCommentMechanicTimesheet.cs.
- Check the generated
- Update Database
dotnet ef database update - Verify
- In SQL Server:
SELECT TOP 1 RejectionComment FROM irby.MechanicTimesheet;
- In SQL Server:
8. Sample Code & CLI Commands
# List pending migrations
dotnet ef migrations list
# Script SQL for this migration
dotnet ef migrations script 20240724175502_AddRejectionCommentMechanicTimesheet
# Apply only this migration
dotnet ef database update 20240724175502_AddRejectionCommentMechanicTimesheet
9. UML Diagram (Mermaid)
classDiagram
class MechanicTimesheet {
+Guid Id
+DateTime StartDate
+string StartTime
+string EndTime
+string RegularTime
+string OverTime
+string PayCode
+string CostType
+string Job
+string WorkOrder
+string UnitNumber
+string SubmittedBy
+int Status
+string Description
+Guid EmployeeId
+string EmployeeName
+string RejectionComment <-- NEW
}
class Employee {
+Guid EmployeeId
+string FirstName
+string LastName
+string Status
+string JdeNumber
}
MechanicTimesheet "1" --> "1" Employee : EmployeeId
10. Conclusion
🔹 20240724175502_AddRejectionCommentMechanicTimesheet.Designer.cs is a critical EF Core snapshot capturing your entire domain model after the addition of the RejectionComment column on the MechanicTimesheet table.
🔹 It ensures consistency of the model when generating future migrations, providing EF Core with the “target” shape of your database.
🔹 Tip: Always review both the migration (Up/Down) and the designer snapshot to fully understand how your schema evolves over time.
Feel free to explore the other entities and navigation configurations in this file to get a comprehensive view of your current schema! 🎉