📄 UpdateFieldOfficeTableWithNewColumns.Designer.cs Documentation
Table of Contents 📑
- Index
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- Data Model Highlights
- Usage & Workflow 🚀
- Mermaid UML Class Diagram 🗺️
- Conclusion 🎯
Index
- File Path
IrbyImaging.DbContext/Migrations/20240201134411_UpdateFieldOfficeTableWithNewColumns.Designer.cs - Class
partial class UpdateFieldOfficeTableWithNewColumns - Namespace
IrbyImaging.DbContext.Migrations
Overview & Purpose
This auto-generated C# file is part of Entity Framework Core’s migration system. It represents the model snapshot after applying the migration named:
20240201134411_UpdateFieldOfficeTableWithNewColumns
Its main responsibilities are:
- Reconstruct the entire EF Core data model in code (tables, columns, keys, indexes, relationships).
- Serve as a point of comparison for EF Core to generate SQL scripts for upgrading or downgrading your database.
- Provide the ‘design-time’ blueprint so that commands like
dotnet ef database updateknow exactly what schema to expect.
Note: You typically do not edit this file manually—changes come from EF Core’s CLI or Visual Studio tools.
Dependencies & Technologies
| Dependency | Version | Purpose |
|---|---|---|
Microsoft.EntityFrameworkCore |
7.0.7 | Core Object–Relational Mapper (ORM) |
Microsoft.EntityFrameworkCore.SqlServer |
7.0.7 | SQL Server provider for EF Core |
Microsoft.EntityFrameworkCore.Design |
7.0.7 | Design‑time utilities (migrations, scaffolding) |
| .NET | 7.x | Target framework |
| C# 11 | — | Language features |
Key Functional Areas
Migration Metadata
[DbContext(typeof(IrbyContext))]
[Migration("20240201134411_UpdateFieldOfficeTableWithNewColumns")]
partial class UpdateFieldOfficeTableWithNewColumns
{ … }
DbContextattribute links this migration to yourIrbyContext.Migrationattribute carries the timestamp + descriptive name—ensuring ordering.
BuildTargetModel Method
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// Suppress warnings about obsolete items
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// … entity definitions follow …
}
- Purpose: Reconstruct the EF Core model for all entities.
- Flow:
- Global annotations (EF Core version, identifier length).
- Identity column strategy for SQL Server.
- Iterate through each entity with
modelBuilder.Entity("FullTypeName", b => { … }).
Entity Configuration
For each entity, EF Core’s fluent‑API is used:
-
Properties
b.Property<Guid>("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier");- Defines CLR → column mapping, nullability, data type, identity behavior.
-
Keys & Indexes
b.HasKey("Id"); b.HasIndex("FieldOfficeId"); b.HasIndex("JdeNumber").IsUnique().HasFilter("[JdeNumber] IS NOT NULL"); -
Table Mapping
b.ToTable("FieldOffice", "irby"); -
Inheritance / TPH Mapping
b.HasDiscriminator<string>("Discriminator") .HasValue("Asset"); b.UseTphMappingStrategy();
Data Model Highlights
FieldOffice Entity 🏢
This migration primarily updates the FieldOffice table by (re)defining its columns:
| Column | SQL Type | Nullable | Description |
|---|---|---|---|
| Id | uniqueidentifier | No | Primary key, GUID identity |
| AsstProjectManagerId | uniqueidentifier | Yes | FK → Employee |
| BusinessUnitName | nvarchar(max) | Yes | Branch business unit name |
| BusinessUnitNumber | nvarchar(max) | Yes | Unit number (string) |
| DirectorId | uniqueidentifier | Yes | FK → Employee |
| FaxNumber | nvarchar(max) | Yes | Fax |
| JdeNumber | nvarchar(450) | Yes | Unique branch code (indexed unique) |
| LeadId | uniqueidentifier | Yes | FK → Employee |
| MailingAddress | nvarchar(max) | Yes | Mailing address |
| ManagerId | uniqueidentifier | Yes | FK → Employee |
| Name | nvarchar(max) | Yes | Office name |
| OfficeExtension | nvarchar(max) | Yes | Phone extension |
| OfficePhone | nvarchar(max) | Yes | Main phone |
| PrimaryContactId | uniqueidentifier | Yes | FK → Employee |
| PrimaryContactPhone | nvarchar(max) | Yes | Contact phone |
| ProjectManagerId | uniqueidentifier | Yes | FK → Employee |
| ProjectManagerPhone | nvarchar(max) | Yes | Project manager’s phone |
| SecondaryContactId | uniqueidentifier | Yes | FK → Employee |
| SecondaryContactPhone | nvarchar(max) | Yes | Secondary contact phone |
| ShippingAddress | nvarchar(max) | Yes | Shipping address |
| SuperintendentId | uniqueidentifier | Yes | FK → Employee |
| SuperintendentPhone | nvarchar(max) | Yes | Superintendent’s phone |
- Relationships:
Each*Idcolumn points toEmployee.EmployeeId, configured with foreign‑key constraints and indexes for fast joins.
Asset Hierarchy & TPH Mapping 💼
- Base Entity:
IrbyImaging.DomainClasses.Asset - Discriminator Column:
"Discriminator" - Derived Types:
Computer,DeskPhone,Dock,MobileDevice,Monitor,NetworkEquipment,OfficePrinter,Printer,SafetyEquipment
Key Highlights:
- Single table (
irby.Asset) holds all subtypes → Table‑per‑Hierarchy (TPH). - Each subtype adds properties (e.g.,
ComputeraddsOperatingSystemId,AssetNumber, etc.) - EF Core fluent‑API uses:
b.HasDiscriminator().HasValue("Computer");
Summary of Other Domain Entities 📋
| Entity | Table (Schema) | Key | Purpose |
|---|---|---|---|
| AssetHistory | irby.AssetHistory | Id (Guid) | Tracks every change to an asset |
| AssetModel | irby.AssetModel | Id (int) | Catalog of asset models |
| AuditDetail | irby.AuditDetail | AuditDetailId (Guid) | Detailed user activity logs |
| BillingInvoice | irby.BillingInvoice | Id (Guid) | Invoices and billing records |
| BlobData | irby.BlobData | BlobDataId (Guid) | Temporary storage for document blobs |
| Customer | irby.Customer | Id (Guid) | Core customer lookup |
| Department | irby.Department | DepartmentId (Guid) | HR department list |
| Job | irby.Job | JobId (Guid) | Project/job master data |
| LinkUserRole | irby.LinkUserRole | Id (Guid) | Junction table for employees ↔ roles |
| Permission | irby.Permissions | PermissionId (Guid) | Permission catalog |
| Role | irby.Role | RoleId (Guid) | Role catalog |
| … and many more |
Tip: Inspect the full list in
BuildTargetModel—each call tomodelBuilder.Entity(...)maps one entity.
Usage & Workflow 🚀
- Create or Update Migration
dotnet ef migrations add UpdateFieldOfficeTableWithNewColumns - Review
- Inspect the generated
.cs(Up/Down methods) & Designer.cs to confirm schema changes.
- Inspect the generated
- Apply to Database
dotnet ef database update - Rollback (if needed)
dotnet ef database update PreviousMigrationName
Mermaid UML Class Diagram 🗺️
classDiagram
class FieldOffice {
+Guid Id
+string Name
+string JdeNumber
+string OfficePhone
+string MailingAddress
+...
}
class Employee {
+Guid EmployeeId
+string FirstName
+string LastName
+string JdeNumber
+...
}
%% Relationships
FieldOffice --> Employee : Manager
FieldOffice --> Employee : Lead
FieldOffice --> Employee : Director
Employee --> Asset : Owns
Asset <|-- Computer
Asset <|-- MobileDevice
Conclusion 🎯
The UpdateFieldOfficeTableWithNewColumns.Designer.cs file is your model snapshot reflecting the database schema after the UpdateFieldOfficeTableWithNewColumns migration.
- It ensures EF Core commands have an accurate blueprint of tables, columns, keys, indexes, and relationships.
- By following the EF Core migrations workflow, you maintain a versioned, auditable, and incremental approach to evolving your database.
- Understanding this file helps debug migration issues, track changes over time, and keep your code‑first model and database schema in perfect sync.
Feel free to refer back to this documentation whenever you need to:
- Verify entity configurations
- Trace foreign‑key setups
- Understand how TPH inheritance is mapped
- Smoothly manage your database migrations!
Happy coding! 🚀
Generated by Entity Framework Core • Auto‑migration snapshot