π IrbyImaging.DbContext Migrations
File: 20220622145439_AddNewCategoryTable.Designer.cs
π Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- Model Snapshot & Fluent API Configuration
4.1. Global Annotations
4.2. Asset Management Entities
4.3. Document Management Entities
4.4. Human Resources Entities
4.5. Billing & Finance Entities
4.6. Other Domain Entities
- Entity Relationships (UML Diagram)
- How to Use & Generate Migrations
- Sample Code Blocks
- Conclusion
1. Overview & Purpose
π What is this file?
This file is an auto-generated EF Core Designer snapshot for the migration named AddNewCategoryTable (timestamp: 20220622145439). It belongs to the IrbyImaging.DbContext assembly and captures the complete database model after applying that migration.
π Why does it exist?
- Enables EF Core to compare the current model against the previous snapshot when you create new migrations.
- Ensures consistency between your C# domain classes and the underlying database schema.
- Do not modify manually; itβs maintained by the EF tooling.
2. Key Functional Areas
- π§ BuildTargetModel: Core method that configures every entity, property, relationship, table mapping, index, discriminator, etc.
- π Attribute Annotations
[DbContext(typeof(IrbyContext))] links this migration to your IrbyContext.
[Migration("20220622145439_AddNewCategoryTable")] marks the unique migration ID.
- π¦ Entity Configuration via Fluent API (
modelBuilder.Entity(...)).
- π Inheritance mapped as Table-Per-Hierarchy (TPH) for
Asset and its derived types.
- π Indexes and Keys defined for performance and constraints.
- π Schema Mapping (
ToTable("...", "irby")) β all objects live in the irby schema.
3. Dependencies & Technologies
| Technology / Package |
Version / Notes |
| .NET Core / .NET 5.0+ |
Target framework |
| Microsoft.EntityFrameworkCore |
5.0.12 (as per annotation) |
| Microsoft.EntityFrameworkCore.Relational |
SQL Server provider |
| Microsoft.EntityFrameworkCore.Migrations |
Migration scaffolding & tooling |
| SQL Server |
Underlying database |
4. Model Snapshot & Fluent API Configuration
4.1 Global Annotations
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.12")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
- MaxIdentifierLength: Limits table & column name length to 128 characters.
- ProductVersion: EF Core version when snapshot was created.
- ValueGenerationStrategy: Default for key generation is
IdentityColumn.
4.2 Asset Management Entities π₯οΈπ¦
| Entity |
Table |
PK Type |
Key Notes |
| Asset |
irby.Asset |
GUID |
Base class for all asset types |
| AssetHistory |
irby.AssetHistory |
GUID |
Tracks changes on assets |
| AssetModel |
irby.AssetModel |
int |
Models of assets (e.g. laptop) |
| AssetModelDetail |
AssetModelDetail |
int |
Additional specs per model |
| Manufacturer |
irby.AssetManufacturer |
int |
Make of the model |
| OperatingSystem |
irby.OperatingSystem |
int |
OS options |
| Computer, DeskPhone, β¦ |
TPH on irby.Asset |
Discriminator |
Derived from Asset |
Highlights
4.3 Document Management Entities ππ
| Entity |
Table |
PK Type |
Description |
| DocumentAttribute |
irby.DocumentAttribute |
GUID |
Defines metadata attributes |
| DocumentCategory |
irby.DocumentCategory |
GUID |
NEW category table added in this migration |
| DocumentType |
irby.DocumentType |
GUID |
Type names, classification |
| DocumentImage |
irby.DocumentImage |
GUID |
Binary contents + OCR data |
| IrbyForms |
irby.IrbyForms |
GUID |
Form images |
| IPMMigration |
irby.IPMMigration |
GUID |
Legacy migration staging |
| TempDocumentData |
irby.TempDocumentData |
GUID |
Temporary ingest table |
Example: DocumentCategory
modelBuilder.Entity("IrbyImaging.DomainClasses.DocumentCategory", b =>
{
b.Property<Guid>("Id").ValueGeneratedOnAdd().HasColumnType("uniqueidentifier");
b.Property<string>("Name").HasColumnType("nvarchar(max)");
b.Property<string>("Description").HasColumnType("nvarchar(max)");
b.Property<bool>("IsAvailable").HasColumnType("bit");
b.Property<bool>("IsDeleted").HasColumnType("bit");
b.Property<string>("AddedBy").HasColumnType("nvarchar(max)");
b.Property<DateTime>("AddedDate").HasColumnType("datetime2");
b.Property<string>("ModifiedBy").HasColumnType("nvarchar(max)");
b.Property<DateTime>("ModifiedDate").HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("DocumentCategory", "irby");
});
4.4 Human Resources Entities π₯π’
| Entity |
Table |
PK Type |
Notes |
| Employee |
irby.Employee |
GUID |
Tracks users with unique JdeNumber |
| FieldOffice |
irby.FieldOffice |
GUID |
Business units, managers, superintendents |
| Job |
irby.Job |
GUID |
JDE job numbers |
| ODSEmployee |
irby.ODS_Employee_Staging |
string |
Staging table for ODS feed |
| ODSJob |
irby.ODS_Jobs_Staging |
string |
Staging table for ODS jobs |
- Unique Index:
Employee.JdeNumber
FieldOffice.JdeNumber
Job.JdeNumber
- Relationships:
Employee β Job (current job)
FieldOffice β Employee (manager, project manager, superintendent)
4.5 Billing & Finance Entities π°π
| Entity |
Table |
PK Type |
Description |
| BillingInvoice |
irby.BillingInvoice |
GUID |
Invoice records |
| GeneralLedger |
irby.GeneralLedger |
GUID |
GL master |
| GLTypeDetail |
GLTypeDetail |
GUID |
GL sub-codes |
| CarrierType |
irby.CarrierType |
GUID |
Carrier categories |
| CarrierTypeDetail |
CarrierTypeDetail |
GUID |
Carrier type child records |
4.6 Other Domain Entities π§©
| Entity |
Table |
PK Type |
Purpose |
| CovidTestData |
irby.CovidTestData |
GUID |
COVID testing records |
| Issue |
irby.Issue |
GUID |
Generic issue catalog |
| RequestOption |
irby.RequestOption |
GUID |
UI dropdown options |
| Ticket |
irby.Ticket |
GUID |
Support tickets |
| Update |
irby.Update |
GUID |
Ticket status history |
5. Entity Relationships (UML Diagram)
classDiagram
%% Base / Derived
Asset <|-- Computer : Discriminator="Computer"
Asset <|-- MobileDevice : Discriminator="MobileDevice"
Asset <|-- DeskPhone : Discriminator="DeskPhone"
Asset <|-- Monitor : Discriminator="Monitor"
Asset <|-- Dock : Discriminator="Dock"
Asset <|-- NetworkEquipment : Discriminator="NetworkEquipment"
Asset <|-- OfficePrinter : Discriminator="OfficePrinter"
Asset <|-- Printer : Discriminator="Printer"
Asset <|-- SafetyEquipment : Discriminator="SafetyEquipment"
%% Asset Relationships
Asset o-- AssetModel : modelId
Asset o-- Employee : ownerId
Asset o-- FieldOffice : fieldOfficeId
%% Model Details
AssetModel "1" o-- "*" AssetModelDetail
AssetModel "*" --> "1" Manufacturer : makeId
%% Document Management
DocumentCategory --> DocumentType : DocumentCategory (string)
DocumentType --> DocumentImage : ReferenceId
%% Ticketing
Ticket "1" o-- "*" Update : ticketId
6. How to Use & Generate Migrations
- π― Add a Migration
dotnet ef migrations add AddNewCategoryTable \
--context IrbyContext
- π Inspect the Generated Files
20220622145439_AddNewCategoryTable.cs β Contains Up() / Down() methods.
20220622145439_AddNewCategoryTable.Designer.cs β Model snapshot (this file).
- π Apply to Database
dotnet ef database update --context IrbyContext
- π Subsequent Migrations
EF Core diff between this snapshot and your current DbContext model to scaffold the next migration.
7. Sample Code Blocks
[DbContext(typeof(IrbyContext))]
[Migration("20220622145439_AddNewCategoryTable")]
partial class AddNewCategoryTable : Migration
{
// This designer file contains BuildTargetModel only.
// The Up/Down are in the main AddNewCategoryTable.cs.
}
7.2 Global Fluent API
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.12")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// Entity configurations go here...
#pragma warning restore 612, 618
}
8. Conclusion
β
This Designer file is a critical part of Entity Framework Coreβs migration infrastructure. It provides a point-in-time snapshot of your entire modelβensuring that future migrations are correctly generated. In this particular migration, the DocumentCategory entity (the βNewCategoryTableβ) was introduced, enabling robust document classification within the IrbyImaging system.
Happy coding & smooth migrations! π
β IrbyImaging Development Team