📦 IrbyImaging.DbContext.Migrations
20240131155030_ApprovalDepartment.Designer.cs
Note:
This file is auto-generated by Entity Framework Core.
It represents the model snapshot at the point of theApprovalDepartmentmigration.
Do not manually edit this file—it will be overwritten on the next migration scaffolding.
📖 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- Entities & Data Models
- Relationships & Navigation Properties
- Migration Configuration & Utilities
- Applying & Rolling Back This Migration
- Usage Examples
- UML Class Diagram (Sample)
- Conclusion
📝 Overview & Purpose
This file is part of the Entity Framework Core migration system. It contains the override of BuildTargetModel(ModelBuilder modelBuilder), which re-creates the database model snapshot at the time the ApprovalDepartment migration was added.
-
Purpose
- Capture the full set of entity configurations (tables, columns, keys, indexes, relationships) in code form.
- Allow EF Core to compute diffs between the current model and previous migrations to generate SQL scripts.
-
When it's generated
- After running
dotnet ef migrations add ApprovalDepartment. - Whenever the model (DbContext or your entity classes) changes, a new migration and designer snapshot are produced.
- After running
🧩 Dependencies & Technologies
| Package | Purpose |
|---|---|
| Microsoft.EntityFrameworkCore | Core ORM framework |
| Microsoft.EntityFrameworkCore.Relational | Relational DB-specific extensions |
| Microsoft.EntityFrameworkCore.SqlServer | SQL Server provider |
| Microsoft.EntityFrameworkCore.Infrastructure | Migration infrastructure |
| Microsoft.EntityFrameworkCore.Storage.ValueConversion | Column type conversions |
⚙️ Key Functional Areas
-
Entity Configuration
- Defines all domain classes under the
IrbyImaging.DomainClassesnamespace. - Maps them to tables (often with
"irby"schema) and configures columns, keys, indexes.
- Defines all domain classes under the
-
Inheritance & Discriminator
- Uses Table‑per‑Hierarchy (TPH) for asset subtypes (Computer, MobileDevice, etc.).
- A
Discriminatorcolumn differentiates derived types.
-
Identity / Auto‑Increment Columns
- Calls
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder)for SQL Server identity columns integration.
- Calls
-
Relationships
- Configures one‑to‑many and many‑to‑one navigation properties via
HasOne,WithMany,HasForeignKey.
- Configures one‑to‑many and many‑to‑one navigation properties via
📊 Entities & Data Models
Below is a high-level grouping of the dozens of entities present in this model snapshot.
Asset Management Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| Asset | irby.Asset |
Id : Guid |
Base class for all assets |
| Computer | irby.Asset |
Id : Guid |
Asset subtype – workstation |
| MobileDevice | irby.Asset |
Id : Guid |
Asset subtype – phone/tablet |
| OfficePrinter | irby.Asset |
Id : Guid |
Asset subtype – print device |
| Monitor, Dock, DeskPhone, NetworkEquipment, Printer, SafetyEquipment | irby.Asset |
Id : Guid |
Other asset subtypes |
| AssetModel | irby.AssetModel |
Id : int |
Model definitions (e.g., “Dell XPS13”) |
| AssetModelDetail | AssetModelDetail |
Id : int |
Detailed configuration for models |
| Manufacturer | irby.AssetManufacturer |
Id : int |
Equipment makers (Dell, HP, etc.) |
| AssetHistory | irby.AssetHistory |
Id : Guid |
Audit trail of asset changes |
Document Imaging Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| BlobData | irby.BlobData |
BlobDataId : Guid |
Raw binary storage for temp images |
| TempDocumentData | irby.TempDocumentData |
TempDocumentDataId |
Staging area for new uploads |
| DocumentImage | irby.DocumentImage |
DocumentImageId |
Finalized scanned documents |
| IrbyForms | irby.IrbyForms |
FormId |
Internal form repository |
| IPMMigration | irby.IPMMigration |
IPMMigrationId |
Bulk migration of images |
| DocumentCategory | irby.DocumentCategory |
Id : Guid |
Classifies by business domain |
| DocumentAttribute | irby.DocumentAttribute |
Id : Guid |
Metadata fields for documents |
| DocumentType | irby.DocumentType |
Id : Guid |
Defines sub‑types per category |
HR & Security Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| Employee | irby.Employee |
EmployeeId : Guid |
Company personnel |
| Department | irby.Department |
DepartmentId : Guid |
Org units |
| Role | irby.Role |
RoleId : Guid |
Security roles |
| Permissions | irby.Permissions |
PermissionId |
Actions allowed by roles |
| LinkUserRole | irby.LinkUserRole |
Id : Guid |
M‑N between User and Role |
| LinkRolePermission | irby.LinkRolePermission |
Id : Guid |
M‑N between Role and Permission |
| AuditDetail | irby.AuditDetail |
AuditDetailId : Guid |
User activity logs |
| AuditReport | irby.AuditReport |
no PK (view) | Read‑only auditing summary |
| TimeEntryType | irby.TimeEntryType |
TimeEntryTypeId |
Types of timesheet rows |
| TimeSheetEntry | irby.TimeSheetEntry |
TimeSheetEntryId |
Daily work hours records |
Financial & Billing Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| BillingInvoice | irby.BillingInvoice |
Id : Guid |
Invoices for carriers |
| CarrierType | irby.CarrierType |
Id : Guid |
Categories of carriers |
| CarrierTypeDetail | CarrierTypeDetail |
Id : Guid |
Specific carrier records |
| GeneralLedger | irby.GeneralLedger |
Id : Guid |
Chart of accounts |
| GLTypeDetail | GLTypeDetail |
Id : Guid |
Sub‑types of general ledger |
Job & Field Office Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| Job | irby.Job |
JobId : Guid |
Construction/Service job orders |
| Customer | irby.Customer |
Id : Guid |
Client master data |
| FieldOffice | irby.FieldOffice |
Id : Guid |
Regional office info |
| ContractTypeDetails | ContractTypeDetails |
no PK (view) | Aggregated contract counts |
| ContractsByLead | ContractsByLead |
no PK (view) | Contracts grouped by director |
| ODS* (ODSCustomer, ODSEmployee, ODSJob) | various | no PK / flattened | External ODS read‑only tables |
Miscellaneous Entities
| Entity | Table (schema) | PK | Description |
|---|---|---|---|
| Ticket | irby.Ticket |
Id : Guid |
IT/Service requests |
| Update | irby.Update |
Id : Guid |
Ticket change history |
| RequestOption | irby.RequestOption |
Id : Guid |
Drop‑down options for requests |
| LicenseReport | LicenseReport |
no PK (view) | License summary |
| LytxTemplate | irby.LytxTemplate |
Id : Guid |
Driver safety data |
| GeoLocations / Lease* | views | no PK | Real‑estate reporting views |
| Issue | irby.Issue |
Id : Guid |
Application issues tracker |
| Vehicle | irby.Vehicle |
Id : Guid |
Fleet vehicles registry |
| State / StatePropertyCosts | irby.State/StatePropertyCosts |
Id/ no PK |
US states & aggregated costs |
🔗 Relationships & Navigation Properties
A few representative relationship configurations:
modelBuilder.Entity<Asset>(b => {
b.HasKey(a => a.Id);
b.HasOne(a => a.Model)
.WithMany(m => m.AssetsModelDetail)
.HasForeignKey(a => a.ModelId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne(a => a.Owner)
.WithMany(e => e.Assets)
.HasForeignKey(a => a.OwnerId);
});
modelBuilder.Entity<Employee>(b => {
b.HasIndex(e => e.JdeNumber)
.IsUnique()
.HasFilter("[JdeNumber] IS NOT NULL");
b.HasOne(e => e.Role)
.WithMany()
.HasForeignKey(e => e.RoleId);
b.HasOne(e => e.Department)
.WithMany()
.HasForeignKey(e => e.DepartmentId);
});
🛠️ Migration Configuration & Utilities
UseIdentityColumns
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
- Enables SQL Server IDENTITY columns for all integer primary keys.
- Equivalent to
[DatabaseGenerated(DatabaseGeneratedOption.Identity)].
Annotations & Discriminator
modelBuilder.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
- Captures EF Core version & database-specific settings.
- Adds a
Discriminatorcolumn on TPH tables (irby.Asset).
🔄 Applying & Rolling Back This Migration
- Apply
dotnet ef database update 20240131155030_ApprovalDepartment - Rollback
dotnet ef database update <PreviousMigrationName>
💡 Usage Examples
1. Query all active assets
using var db = new IrbyContext();
var activeAssets = db.Assets
.Where(a => a.Status == "Active")
.Include(a => a.Owner)
.Include(a => a.Model)
.ToList();
2. Add a new DocumentImage
var doc = new DocumentImage {
DocumentImageId = Guid.NewGuid(),
FileName = "Lease.pdf",
ImageContents = await File.ReadAllBytesAsync("Lease.pdf"),
DocumentUploadedBy = "[email protected]",
DocumentUploadedDate = DateTime.UtcNow
};
db.DocumentImages.Add(doc);
db.SaveChanges();
🖼️ UML Class Diagram (Sample)
classDiagram
class Manufacturer {
+int Id
+string Name
+short? WarrantyMonths
}
class AssetModel {
+int Id
+string Name
+int MakeId
}
class Asset {
+Guid Id
+int ModelId
+Guid? OwnerId
+string Status
}
class Employee {
+Guid EmployeeId
+string FirstName
+string LastName
}
Manufacturer "1" o-- "many" AssetModel : makes
AssetModel "1" o-- "many" Asset : defines
Employee "1" o-- "many" Asset : owns
✅ Conclusion
This *.Designer.cs file is a snapshot of the EF Core model at the time of the ApprovalDepartment migration. It:
- Defines all the database tables, columns, keys, indexes, and relationships.
- Enables EF Core to compute subsequent migrations by diffing against this snapshot.
- Should be treated as a generated artifact—any manual changes will be lost.
By reviewing this file, you can gain a comprehensive, code‑first view of your database schema and how your domain classes are mapped to SQL Server tables.