📑 ApprovalRequired Migration Designer Documentation
File:
IrbyImaging.DbContext/Migrations/20231219153038_ApprovalRequired.Designer.cs
🗂 Table of Contents
- Overview & Purpose
- Migration Class & BuildTargetModel
- EF Core Configuration & Annotations
- Entity Model Overview
4.1. Asset Management Entities
4.2. Document Imaging Entities
4.3. Auditing & Security Entities
4.4. Billing & Accounting Entities
4.5. HR & Time Tracking Entities - Inheritance & Discriminator Strategy
- Relationships & Navigation Properties
- Dependencies & Technologies
- Usage & Commands
- Class Diagram / UML
- Conclusion
1. Overview & Purpose
This auto-generated designer file represents the EF Core model snapshot at the time of the ApprovalRequired migration (timestamp 20231219153038).
- It defines how the database schema should look after applying this migration.
- It drives commands like
dotnet ef database updateand forms the basis for model comparisons in future migrations. - Important: Do not manually edit this file; it is regenerated whenever you add or remove migrations.
2. Migration Class & BuildTargetModel
[DbContext(typeof(IrbyContext))]
[Migration("20231219153038_ApprovalRequired")]
partial class ApprovalRequired : Migration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// Fluent API configurations for all entities...
}
}
DbContextattribute ties this toIrbyContext.Migrationattribute names it"20231219153038_ApprovalRequired".BuildTargetModeluses theModelBuilderto re-create the EF Core model for this migration step.
3. EF Core Configuration & Annotations
At the top of BuildTargetModel, global annotations are set:
| Annotation | Value | Purpose |
|---|---|---|
ProductVersion |
"7.0.7" |
EF Core version used |
Relational:MaxIdentifierLength |
128 |
Maximum length for column/table identifiers |
UseIdentityColumns() |
— | Enable SQL Server identity columns (PKs) |
Each entity is then configured via Fluent API methods:
modelBuilder.Entity(...)– begins configuration of an entity type.HasKey(...),HasIndex(...),ToTable(...)– configure keys, indexes, and table mappings.- Property mapping:
b.Property<Guid>("Id") .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier");
4. Entity Model Overview
The snapshot covers 70+ domain classes. They can be grouped by functional area:
4.1. Asset Management Entities 🚚
| Entity | Schema.Table | PK | Key Properties |
|---|---|---|---|
| Asset | irby.Asset | Id:Guid |
Category, SerialNumber, NeedsReview (bit) |
| Computer | irby.Asset | Id |
Inherits from Asset + OperatingSystemId, UnitNumber |
| MobileDevice | irby.Asset | Id |
Carrier, Imei (unique), PhoneNumber |
| OfficePrinter | irby.Asset | Id |
Company, ContractEndDate |
| SafetyEquipment | irby.Asset | Id |
Inherits Asset + AssetNumber, CpsNumber |
| AssetModel | irby.AssetModel | Id:Int |
Name, Category, MakeId → Manufacturer |
| AssetHistory | irby.AssetHistory | Id:Guid |
Action, AssetId, Timestamp |
4.2. Document Imaging Entities 📄
| Entity | Schema.Table | PK | Description |
|---|---|---|---|
| DocumentImage | irby.DocumentImage | DocumentImageId:Guid |
Stores scanned image, OCR text, metadata |
| TempDocumentData | irby.TempDocumentData | TempDocumentDataId |
Staging area for uploaded documents |
| BlobData | irby.BlobData | BlobDataId |
Raw byte[] storage for images |
| DocumentType | irby.DocumentType | Id:Guid |
Catalog of document types |
| DocumentAttribute | irby.DocumentAttribute | Id:Guid |
Attributes/metadata definitions |
4.3. Auditing & Security Entities 🔒
| Entity | Schema.Table | PK | Notes |
|---|---|---|---|
| AuditDetail | irby.AuditDetail | AuditDetailId |
Per‐action log (Area, ControllerName, UserId) |
| AuditReport | dbo.AuditReport | No PK defined | Flattened view for reporting |
| Permissions | irby.Permissions | PermissionId |
Application permissions |
| Role | irby.Role | RoleId |
User roles |
| LinkRolePermission | irby.LinkRolePermission | Id |
M‑N linking roles ↔ permissions |
| LinkUserRole | irby.LinkUserRole | Id |
M‑N linking users ↔ roles |
4.4. Billing & Accounting Entities 💰
| Entity | Schema.Table | PK | Description |
|---|---|---|---|
| BillingInvoice | irby.BillingInvoice | Id:Guid |
Invoices / charges |
| GeneralLedger | irby.GeneralLedger | Id:Guid |
GL accounts |
| GLTypeDetail | dbo.GLTypeDetail | Id:Guid |
GL sub‐categories |
| CarrierType | irby.CarrierType | Id:Guid |
Carriers (vendors) |
| CarrierTypeDetail | irby.CarrierTypeDetail | Id:Guid |
Carrier sub‐types |
4.5. HR & Time Tracking Entities 👥
| Entity | Schema.Table | PK | Description |
|---|---|---|---|
| Employee | irby.Employee | EmployeeId |
Employee master record |
| Department | irby.Department | DepartmentId |
Organization departments |
| Job | irby.Job | JobId |
Project/job data |
| TimeEntryType | irby.TimeEntryType | TimeEntryTypeId |
Types of time (regular, overtime) |
| TimeSheetEntry | irby.TimeSheetEntry | TimeSheetEntryId |
Individual time entries |
| Ticket | irby.Ticket | Id:Guid |
Service / IT tickets |
| Update | irby.Update | Id:Guid |
Ticket updates (audit trail) |
5. Inheritance & Discriminator Strategy
Table‐Per‐Hierarchy (TPH) strategy for the Asset root entity.
classDiagram
Asset <|-- Computer
Asset <|-- MobileDevice
Asset <|-- DeskPhone
Asset <|-- OfficePrinter
Asset <|-- SafetyEquipment
- Shared table
irby.Asset Discriminatorcolumn holds values:“Asset”,“Computer”,“MobileDevice”, etc.- All subtype‐specific properties are nullable in the same table.
6. Relationships & Navigation Properties 🔗
| Principal | Dependent | FK Property | Navigation |
|---|---|---|---|
| Asset | FieldOffice | FieldOfficeId |
Asset.FieldOffice |
| Asset | AssetModel | ModelId |
Asset.Model |
| Asset | Employee (Owner) | OwnerId |
Asset.Owner |
| AssetModel | Manufacturer | MakeId |
AssetModel.Make |
| Employee | Department | DepartmentId |
Employee.Department |
| Employee | Job | JobId |
Employee.Job |
| AuditDetail | Employee (User) | EmployeeId |
AuditDetail.User |
| LinkRolePermission | Role / Permissions (M‑N) | RoleId, PermissionId |
— |
| TimeSheetEntry | Employee / TimeEntryType | EmployeeId, TimeEntryTypeId |
— |
Navigation properties are configured via
HasOne(…)…WithMany(…)…HasForeignKey(…)inBuildTargetModel.
7. Dependencies & Technologies 🛠️
- .NET 7.0 (C# 11)
- Entity Framework Core 7.0.7
- Packages:
Microsoft.EntityFrameworkCoreMicrosoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.Design
- Packages:
- SQL Server (Identity columns)
- Schema: Many tables under the
"irby"schema; some under defaultdbo.
8. Usage & Commands 🚀
# Add a new migration
dotnet ef migrations add ApprovalRequired
# Update the database
dotnet ef database update
- The
.Designer.csfile is generated alongside the main*.csmigration. - Do not modify manually; EF Core scaffolds it.
9. Class Diagram / UML
classDiagram
%% Asset Inheritance Hierarchy
class Asset {
+Guid Id
+string Category
+bool NeedsReview
+DateTimeOffset PurchaseDate
+...
}
class Computer {
+string AssetNumber
+int OperatingSystemId
+...
}
Asset <|-- Computer
Asset <|-- MobileDevice
Asset <|-- DeskPhone
Asset <|-- OfficePrinter
Asset <|-- SafetyEquipment
%% Related Entities
class AssetModel {
+int Id
+string Name
}
class Manufacturer {
+int Id
+string Name
}
AssetModel --> Manufacturer : Make
Asset --> AssetModel : Model
Asset --> Employee : Owner
Employee --> Department
TimeSheetEntry --> Employee
TimeSheetEntry --> TimeEntryType
10. Conclusion ✅
The ApprovalRequired designer snapshot codifies the entire Entity Framework Core model at this migration step.
- It ensures schema consistency and drives automatic database updates.
- Covers a broad domain: asset management, document imaging, auditing, billing, HR/time tracking.
- Keep it under source control, but avoid manual edits—rely on
dotnet ef migrationsto maintain it.
Happy coding! 🎉