📑 AddJobColumnToClassificationTable.Designer.cs Documentation
📚 Table of Contents
- Overview & Purpose
- Context: EF Core Migrations
- Key Functional Area:
BuildTargetModel
3.1 Model Annotations & Conventions
3.2 Use of Identity Columns - Entity Mappings & Highlight:
JobClassification
4.1JobClassificationTable Schema
4.2 Foreign‑Key Relationship toJob - Other Domain Entities (at a Glance)
- Dependencies & Technologies
- How to Use This Migration
- UML Diagram:
Job↔JobClassification - Conclusion
1. Overview & Purpose
File: AddJobColumnToClassificationTable.Designer.cs
Namespace: IrbyImaging.DbContext.Migrations
Migration: 20250116171432_AddJobColumnToClassificationTable
This auto‑generated designer file is part of an Entity Framework Core migration that adds a
JobIdcolumn and foreign‑key relationship to theJobClassificationtable. It also captures the full model snapshot (BuildTargetModel) so EF Core can compare schema changes and generate appropriate SQL.
2. Context: EF Core Migrations
EF Core Migrations maintain an up-to-date database schema in sync with your C# domain classes:
-
Migration Attributes
[DbContext(typeof(IrbyContext))]: Targets theIrbyContext.[Migration("20250116171432_AddJobColumnToClassificationTable")]: Unique timestamp + descriptive name.
-
Designer File
- Contains
BuildTargetModel(ModelBuilder modelBuilder) - Captures the full entity model snapshot after this migration is applied.
- Contains
3. Key Functional Area: BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// … Entity configurations follow …
#pragma warning restore 612, 618
}
3.1 Model Annotations & Conventions
| Annotation | Purpose |
|---|---|
ProductVersion = "9.0.0" |
EF Core version used for migration generation |
Relational:MaxIdentifierLength = 128 |
SQL Server max length for identifiers (tables, columns) |
3.2 Use of Identity Columns
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
Applies SQL Server's Identity strategy for auto‑incrementing primary keys (e.g.
INT IDENTITY).
4. Entity Mappings & Highlight: JobClassification
The migration focuses on the JobClassification entity by adding:
JobIdforeign‑key column (typeuniqueidentifier)- An index on
JobId - A cascade delete relationship to
Job
4.1 JobClassification Table Schema
| Property | CLR Type | SQL Type | Notes |
|---|---|---|---|
JobClassificationId |
Guid |
uniqueidentifier |
Primary key, generated on add |
ClassNumber |
int |
int |
Classification code |
City |
string |
nvarchar(max) |
Location |
County |
string |
nvarchar(max) |
Location |
FringeAmount |
decimal |
decimal(18,2) |
Fringe amount |
ImageOCRContents |
byte[] |
varbinary(max) |
OCR image data |
ImageOCRText |
string |
nvarchar(max) |
OCR extracted text |
JobId |
Guid |
uniqueidentifier |
New FK column |
modelBuilder.Entity("IrbyImaging.DomainClasses.JobClassification", b =>
{
b.Property<Guid>("JobClassificationId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
// … other properties …
b.Property<Guid>("JobId")
.HasColumnType("uniqueidentifier");
b.HasKey("JobClassificationId");
b.HasIndex("JobId");
b.ToTable("JobClassification", "irby");
});
4.2 Foreign‑Key Relationship to Job
modelBuilder.Entity("IrbyImaging.DomainClasses.JobClassification", b =>
{
b.HasOne("IrbyImaging.DomainClasses.Job", "Job")
.WithMany() // No navigation back from JobClassification
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
- Cascade Delete: Deleting a
Jobwill delete itsJobClassificationrows. - Index on
JobIdfor performance.
5. Other Domain Entities (at a Glance)
Beyond JobClassification, over 100 domain classes are mapped. Here’s a snapshot:
| Entity Name | Table Schema | Notes |
|---|---|---|
AccountBalances |
irby.AccountBalances |
Account balance reporting |
Asset (TPH) |
irby.Asset |
Inheritance via Discriminator for various assets |
Employee |
irby.Employee |
Staff directory with unique JdeNumber |
Job |
irby.Job |
Central to many relationships (employees, POs) |
FieldOffice |
irby.FieldOffice |
Office locations with staff assignments |
PurchaseOrder |
irby.PurchaseOrder |
Linked to Job |
WorkOrder |
irby.WorkOrder |
Equipment maintenance tasks |
| …and many more… |
All entities include configurations for keys, indexes, table schemas, and relationships. Refer to the full file for details.
6. Dependencies & Technologies
- .NET 7 / EF Core 9.0.0
- SQL Server (relational provider, Identity columns)
- Auto‑generated by
dotnet ef migrations add
7. How to Use This Migration
- Add Migration
dotnet ef migrations add AddJobColumnToClassificationTable - Update Database
dotnet ef database update - Verify Changes
- Check
JobClassificationtable structure in your SQL Server. - Confirm
JobIdforeign key and cascade behavior.
- Check
8. UML Diagram: Job ↔ JobClassification
classDiagram
class Job {
+Guid JobId
+string Name
+...
}
class JobClassification {
+Guid JobClassificationId
+int ClassNumber
+Guid JobId
+...
}
Job "1" --> "*" JobClassification : HasMany
- 1: A single
Jobcan have manyJobClassificationrecords. - ★ Cascade delete keeps referential integrity.
9. Conclusion
This designer file captures the model snapshot after the AddJobColumnToClassificationTable migration. It ensures that:
JobClassificationhas a new, indexedJobIdcolumn.- Proper relationships and cascade rules are in place.
- The rest of the domain model remains consistent for EF Core to track future changes.
🎉 You’re now equipped to apply, review, and extend this migration in your IrbyImaging solution!