📑 Migration Documentation: 20220303180613_AddJDENumber.Designer.cs
Assembly: IrbyImaging.DbContext
Namespace:IrbyImaging.DbContext.Migrations
Author: kvamshi
Created/Modified: 03‑31‑2022
📑 Table of Contents
- Overview & Purpose
- Migration Class Metadata
- BuildTargetModel Method
- Key Functional Areas
- Dependencies & Technologies
- Usage & Code Snippets
- Sample UML Diagram
- Conclusion
Overview & Purpose
This EF Core designer file is part of the AddJDENumber migration. It captures a snapshot of your DbContext model at the point when the migration was generated.
- 🔄 Purpose: Provide EF Core with the complete model structure (tables, columns, keys, indexes, relationships, inheritance mappings, etc.) so it can compute diffs when applying or rolling back migrations.
- 📦 Scope: Describes 30+ domain entities under the
"irby"schema, including assets, employees, jobs, document images, billing, staging tables, and more.
Note: This file is auto-generated. Do not edit manually—use
dotnet ef migrations add/update-databaseto keep migrations in sync.
Migration Class Metadata
[DbContext(typeof(IrbyContext))]
[Migration("20220303180613_AddJDENumber")]
partial class AddJDENumber : Migration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder) { ... }
}
| Attribute | Description |
|---|---|
[DbContext(typeof…)] |
Binds this migration to the IrbyContext. |
[Migration("…AddJDENumber")] |
Unique identifier & timestamp for this migration. |
partial class AddJDENumber |
Allows EF to generate additional code in another partial file. |
BuildTargetModel Method
This core method configures the EF Core metadata to mirror your domain classes at migration time.
3.1 Core Annotations
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.12")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
- MaxIdentifierLength: Max length for SQL identifiers.
- ProductVersion: EF Core version used to scaffold.
- ValueGenerationStrategy: Defaults to identity columns for numeric PKs.
3.2 Entity Mappings
Below is a representative table of a few key entities (over 30 exist in this snapshot). Each row summarizes table, PK, major indexes & remarks.
| Entity Class | Table (Schema) | Primary Key | Major Indexes | Comments |
|---|---|---|---|---|
Asset |
irby.Asset | Id : uniqueidentifier |
FieldOfficeId, ModelId, OwnerId |
Base type for many discriminated assets |
Employee |
irby.Employee | Id : uniqueidentifier |
CurrentJobId, JdeNumber (unique) |
JDE number added by this migration |
FieldOffice |
irby.FieldOffice | Id : uniqueidentifier |
JdeNumber (unique), ManagerId |
|
Job |
irby.Job | Id : uniqueidentifier |
JdeNumber (unique) |
|
BillingInvoice |
irby.BillingInvoice | Id : uniqueidentifier |
― | Contains JDENumber column |
DocumentImage |
irby.DocumentImage | DocumentImageId |
― | Large binary/image data |
ODS_Employee_Staging |
irby.ODS_Employee_Staging | EMPLOYEE_NUMBER |
Alternate key on ORG_BU |
Staging table for ODS refresh |
AssetModel |
irby.AssetModel | Id : int |
MakeId |
Contains manufacturer relationship |
- AssetHistory
- AssetModelDetail
- CarrierType + CarrierTypeDetail
- CovidTestData
- GLTypeDetail & GeneralLedger
- IPMMigration & TempDocumentData
- Manufacturer (AssetManufacturer)
- OperatingSystem
- …and several specialized asset subclasses (Computer, MobileDevice, DeskPhone, etc.)
3.3 Inheritance & Discriminators
Many asset types inherit from the base Asset:
modelBuilder.Entity("IrbyImaging.DomainClasses.Computer", b =>
{
b.HasBaseType("IrbyImaging.DomainClasses.Asset");
b.Property<string>("AssetNumber")…;
b.HasDiscriminator().HasValue("Computer");
});
// … similarly for MobileDevice, DeskPhone, Monitor, etc.
- Table-per-Hierarchy (TPH) pattern:
- All assets share
irby.Assettable. - Discriminator column (nvarchar) distinguishes
Computer,Printer,Dock, etc.
- All assets share
3.4 Relationships & Navigations
EF Core relationships (one-to-many, many-to-one) are configured with .HasOne() / .WithMany():
// Asset → FieldOffice (many assets per office)
modelBuilder.Entity("Asset", b =>
b.HasOne("FieldOffice","FieldOffice")
.WithMany("Assets")
.HasForeignKey("FieldOfficeId"));
// Employee → Job (many employees per job)
modelBuilder.Entity("Employee", b =>
b.HasOne("Job","CurrentJob")
.WithMany("Employees")
.HasForeignKey("CurrentJobId"));
🔗 Navigations (exposed on domain classes) are also registered for lazy/eager loading.
Key Functional Areas 🛠️
-
Asset Management
- TPH mapping for all
Assetsubtypes. - Query by status, owner, model, office.
- TPH mapping for all
-
Human Resources (JDE Integration)
- Uniqueness enforcement on
JdeNumberinEmployee,FieldOffice,Job. - Staging tables for ODS (Operational Data Store) refresh.
- Uniqueness enforcement on
-
Document & Imaging Pipeline
- Raw document ingestion (
TempDocumentData,IPMMigration). - OCR, indexing flags, binary storage.
- Raw document ingestion (
-
Billing & GL
BillingInvoicewith JDE & GL references.GeneralLedger&GLTypeDetailmappings.
-
Historical Auditing
AssetHistorysnapshots of asset changes.- Serialized properties for rollback/audit.
Dependencies & Technologies 🔌
- Entity Framework Core 5.0.12
- Package:
Microsoft.EntityFrameworkCore.SqlServer
- Package:
- .NET 5.0
- SQL Server
- Identity columns, nvarchar(max), varbinary(max).
- Domain Classes Assembly
IrbyImaging.DomainClasses.*
Usage & Code Snippets 🚀
Applying the Migration
# From project root
dotnet ef database update 20220303180613_AddJDENumber
Rolling Back
dotnet ef database update <previous_migration_name>
Inspecting the Model
Use the IrbyContext to introspect:
using(var context = new IrbyContext())
{
var employee = context.Employees
.Where(e => e.JdeNumber == "12345")
.FirstOrDefault();
// …
}
Sample UML Diagram
@startuml
class Employee {
Guid Id
string JdeNumber
Guid CurrentJobId
}
class Job {
Guid Id
string JdeNumber
}
class Asset {
Guid Id
string SerialNumber
string Discriminator
}
class FieldOffice {
Guid Id
string JdeNumber
}
Employee "1" --> "1" Job : CurrentJob
Employee "0..*" --> "0..*" Asset : Owner
FieldOffice "1" --> "0..*" Asset : FieldOffice
@enduml
Copy the above into a PlantUML editor to visualize entity relationships.
Conclusion ✅
The 20220303180613_AddJDENumber.Designer.cs file is a snapshot of your EF Core model at the time the AddJDENumber migration was scaffolded. It defines all tables, columns, keys, indexes, inheritance hierarchies, and relationships necessary for EF to generate/up‑date your database schema.
Tip: Always keep designer files under source control, but avoid manual edits. Use migrations commands to evolve your model safely.
Happy coding! 🛠️📦