📖 Documentation for 20230711153123_AddCategoryColumn.Designer.cs
Location:
IrbyImaging.DbContext/Migrations/20230711153123_AddCategoryColumn.Designer.cs
Generated By: Entity Framework Core Migrations (auto-generated)
Migration Name:AddCategoryColumn
🚀 Table of Contents
- 🔍 Overview & Purpose
- ⚙️ Dependencies & Technologies
- 🏗️ Migration File Structure
- 🗄️ Entity Data Models
- 4.1. Asset‑Related Models
- 4.2. Document‑Related Models
- 4.3. Billing, Ticketing, Auditing Models
- 4.4. ODS & Integration Staging Models
- ➕ Category Column Addition
- 🛠️ BuildTargetModel Explained
- 🔗 Relationships & Navigation Properties
- 🚀 How to Apply / Use the Migration
- 🧩 Third‑Party Integrations
- 🎉 Conclusion
🔍 Overview & Purpose
This Designer file is an auto‐generated snapshot of the Entity Framework Core model after applying the AddCategoryColumn migration. It defines:
- The complete schema of all database tables (
irbyschema). - Data types, keys, indices, property configurations, and relationships between entities.
- A category column added to specific entities so that assets and asset models can be grouped or filtered by category.
Note:
- Do not modify this file manually – it is managed by EF Core.
- Alterations should be done via EF Migrations (Up/Down in the main migration file), then re‑scaffolded.
⚙️ Dependencies & Technologies
| Technology | Version | Purpose |
|---|---|---|
| Microsoft.EntityFrameworkCore | 7.0.7 | ORM, model building, migrations |
| Microsoft.EntityFrameworkCore.SqlServer | 7.0.7 | SQL Server provider |
| C# / .NET 7.0 | — | Language & runtime |
| SQL Server | ≥ 2016 | Target database |
🏗️ Migration File Structure
namespace IrbyImaging.DbContext.Migrations
{
[DbContext(typeof(IrbyContext))]
[Migration("20230711153123_AddCategoryColumn")]
partial class AddCategoryColumn
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// 1. Annotations (product version, identifiers)
// 2. Identity column strategies
// 3. All entity configurations
// 4. Table & schema mapping
// 5. Discriminator (TPH) for Asset hierarchy
// 6. Relationships & navigation setup
}
}
}
- Attributes
[DbContext(typeof(IrbyContext))]: Indicates the context class.[Migration("20230711153123_AddCategoryColumn")]: Unique timestamped migration ID.
- BuildTargetModel
- Constructs the EF Core model snapshot, used for future diffs and ensuring consistency.
🗄️ Entity Data Models
Below is a high‑level grouping of the entities configured in this migration. All tables are in the irby schema unless otherwise noted.
4.1. Asset‑Related Models
| Entity | Table | Notes |
|---|---|---|
Asset |
irby.Asset |
Base type (TPH) with discriminator “Asset” |
Computer |
irby.Asset |
Inherits Asset (Discriminator = “Computer”) |
DeskPhone |
irby.Asset |
… “DeskPhone” |
Dock |
irby.Asset |
… “Dock” |
MobileDevice |
irby.Asset |
Carrier, IMEI, Telogis flag |
Monitor |
irby.Asset |
… “Monitor” |
NetworkEquipment |
irby.Asset |
… “NetworkEquipment” |
OfficePrinter |
irby.Asset |
Company, ContractEndDate |
Printer |
irby.Asset |
… “Printer” |
SafetyEquipment |
irby.Asset |
AssetNumber, CPSNumber, OS, UnitNumber |
AssetHistory |
irby.AssetHistory |
Tracks changes & status history |
AssetModel |
irby.AssetModel |
Models metadata (Name, Type, Category...) |
AssetModelDetail |
AssetModelDetail |
Details per model + Category integer |
Manufacturer |
irby.AssetManufacturer |
Makers of assets |
OperatingSystem |
irby.OperatingSystem |
OS options for Computers / SafetyEquipment |
4.2. Document‑Related Models
| Entity | Table | Notes |
|---|---|---|
DocumentAttribute |
irby.DocumentAttribute |
Custom attributes, types, flags |
DocumentCategory |
irby.DocumentCategory |
Category lookup |
DocumentType |
irby.DocumentType |
Document type definitions |
DocumentImage |
irby.DocumentImage |
Binary image/OCR content, tagging |
TempDocumentData |
irby.TempDocumentData |
Staging for indexing, blob linking |
BlobData |
irby.BlobData |
Raw binary data |
IPMMigration |
irby.IPMMigration |
Legacy migration staging |
IrbyForms |
irby.IrbyForms |
PDF/form image storage |
4.3. Billing, Ticketing, Auditing Models
-
Billing & Carrier
BillingInvoice(irby.BillingInvoice)CarrierType/CarrierTypeDetail
-
Ticketing & Updates
Ticket(irby.Ticket)Update(irby.Update)
-
Time & Payroll
TimeEntryType(irby.TimeEntryType)TimeSheetEntry(irby.TimeSheetEntry)
4.4. ODS & Integration Staging Models
| Entity | Table | Purpose |
|---|---|---|
ODSJob |
ODS_Jobs_Staging |
Staging table for ODS job data |
ODSEmployee |
ODS_Employee_Staging |
Staging table for employees |
➕ Category Column Addition
This migration introduces a Category field to various entities to enable richer classification:
| Entity | Property | Type | Required? |
|---|---|---|---|
Asset |
Category |
string |
Yes |
AssetModel |
Category |
string |
Yes |
AssetModelDetail |
Category |
int |
No |
Plus many document/ticket/time‑entry tables also have a Category or AttributeType column. |
Why?
- Filter assets by category (e.g., “Computer”, “Safety”).
- Model‑level grouping for drop‑down selection.
- Allow integer‑backed enums on detail tables.
🛠️ BuildTargetModel Explained
Inside BuildTargetModel(ModelBuilder modelBuilder), EF Core:
-
Sets annotations:
modelBuilder .HasAnnotation("ProductVersion", "7.0.7") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); -
Defines every entity via
modelBuilder.Entity("FullTypeName", b => { ... }). -
Configures each property:
b.Property<Guid>("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); -
Sets primary keys & indices:
b.HasKey("Id"); b.HasIndex("FieldOfficeId"); -
Maps to table & schema:
b.ToTable("Asset", "irby"); -
Configures Table‑Per‑Hierarchy (TPH) inheritance for
Assetand its subtypes using.HasDiscriminator(). -
Defines relationships & navigation via
HasOne(...).WithMany(...)calls.
🔗 Relationships & Navigation Properties
Below is a sample of how relationships are wired:
// Asset → FieldOffice (many assets belong to one office)
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b =>
{
b.HasOne("IrbyImaging.DomainClasses.FieldOffice", "FieldOffice")
.WithMany("Assets")
.HasForeignKey("FieldOfficeId");
});
// AssetModel → Manufacturer (many models per manufacturer)
modelBuilder.Entity("IrbyImaging.DomainClasses.AssetModel", b =>
{
b.HasOne("IrbyImaging.DomainClasses.Manufacturer", "Make")
.WithMany("Models")
.HasForeignKey("MakeId")
.OnDelete(DeleteBehavior.Cascade);
});
UML Class Diagram (Excerpt)
@startuml
class Asset {
+Guid Id
+string Category
+string Status
--
+FieldOfficeId
+OwnerId
+ModelId
}
class AssetModel {
+int Id
+string Category
+string Name
}
class Manufacturer {
+int Id
+string Name
}
AssetModel --> Manufacturer : Make
Asset --> AssetModel : Model
Asset --> FieldOffice
@enduml
🚀 How to Apply / Use the Migration
- Ensure EF Core Tools are installed:
dotnet tool install --global dotnet-ef - Add & Update (if not already done):
dotnet ef migrations add AddCategoryColumn - Review the generated
*.csfiles inMigrations/. - Apply to your database:
dotnet ef database update 20230711153123_AddCategoryColumn - Verify the new
Categorycolumns exist in target tables (SELECT TOP 1 Category FROM irby.Asset;).
🧩 Third‑Party Integrations
- Entity Framework Core – automatically generates this file.
- SQL Server – target RDBMS for identity/column mapping.
- PlantUML – optional for diagramming your model relationships.
🎉 Conclusion
The 20230711153123_AddCategoryColumn.Designer.cs file is a complete snapshot of your EF Core model after adding Category columns to key tables. It ensures:
- Consistency: EF Core knows exactly how your database is structured.
- Migrations: Future schema changes will be correctly diffed against this snapshot.
- Documentation: Serves as a code‐first reference for all entities, properties, and relationships.
✨ With this migration applied, your application can now categorize assets and models more flexibly, enabling richer data queries and UI grouping!