📑 Table of Contents
- Overview & Purpose
- Migration Details
- BuildTargetModel Explained
- Domain Entities & Data Models
- Entity Relationship Diagram (UML)
- Dependencies & Technologies
- Usage & Examples
- Best Practices
- Conclusion
🔍 Overview & Purpose
File:
IrbyImaging.DbContext/Migrations/20230711141837_RemoveHrColumns.Designer.cs
This is an auto-generated EF Core migration designer file. It represents the target database schema after applying the RemoveHrColumns migration.
ℹ️ Note: Designer files mirror your C# model into a database snapshot. Do not edit manually—they are regenerated on each
dotnet ef migrations addcommand.
Key Goals:
- Capture all entities, properties, keys and relationships of your domain at this migration point.
- Drive
Update-Databaseordotnet ef database updateto sync the database.
🛠️ Migration Details
| Attribute | Value |
|---|---|
| Migration ID | 20230711141837_RemoveHrColumns |
| DbContext | IrbyContext |
| Target .NET / EF Core Version | .NET 7.0 / EF Core 7.0.7 |
| Database Provider | Microsoft.EntityFrameworkCore.SqlServer |
[DbContext(typeof(IrbyContext))]
[Migration("20230711141837_RemoveHrColumns")]
partial class RemoveHrColumns
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// .. entity configurations
}
}
🏗️ BuildTargetModel Explained
The BuildTargetModel method rebuilds your model snapshot:
-
Model Metadata
modelBuilder .HasAnnotation("ProductVersion", "7.0.7") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); -
Entity Configuration
For each entity, EF configures:- Properties (
b.Property<type>("Name")) - Keys (
b.HasKey("PK_Name")) - Indices (
b.HasIndex("Field")) - Table & Schema (
b.ToTable("Name", "irby")) - Inheritance (TPH via
.HasDiscriminator())
- Properties (
-
Relationships
Defined via:b.HasOne("Namespace.Class", "Navigation") .WithMany("Collection") .HasForeignKey("ForeignKeyField") .OnDelete(DeleteBehavior.Cascade);
🚧 Warning: Large migrations can be memory-intensive. Consider breaking them into smaller logical steps when possible.
📂 Domain Entities & Data Models
Below is a high‐level grouping of entities defined in the model:
Asset Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
Asset |
Asset | irby | Base class (TPH) |
Computer |
Asset | irby | Inherits Asset, has OperatingSystemId |
DeskPhone |
Asset | irby | Inherits Asset |
Dock |
Asset | irby | Inherits Asset |
MobileDevice |
Asset | irby | Unique Imei, custom column mapping |
Monitor |
Asset | irby | Inherits Asset |
NetworkEquipment |
Asset | irby | Inherits Asset |
OfficePrinter |
Asset | irby | Adds Company, ContractEndDate |
Printer |
Asset | irby | Inherits Asset |
SafetyEquipment |
Asset | irby | Similar to Computer, TPH discriminator |
Document & Blob Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
BlobData |
BlobData | irby | Stores binary/image data |
TempDocumentData |
TempDocumentData | irby | Staging area |
DocumentImage |
DocumentImage | irby | Full document & OCR fields |
DocumentAttribute |
DocumentAttribute | irby | Metadata attribute listing |
DocumentCategory |
DocumentCategory | irby | Document grouping |
DocumentType |
DocumentType | irby | Type definitions |
IPMMigration |
IPMMigration | irby | Legacy migration staging |
IrbyForms |
IrbyForms | irby | Custom forms storage |
Employee, Job & Office Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
Employee |
Employee | irby | Unique JdeNumber, CurrentJob |
ODSEmployee |
ODS_Employee_Staging | irby | Staging table, alternate key |
Job |
Job | irby | Unique JdeNumber |
ODSJob |
ODS_Jobs_Staging | irby | Staging |
FieldOffice |
FieldOffice | irby | Managers & superintendents |
Customer |
Customer | irby | Basic customer lookup |
Billing & Financial Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
BillingInvoice |
BillingInvoice | irby | Invoice header data |
CarrierType |
CarrierType | irby | Shipping carriers |
CarrierTypeDetail |
CarrierTypeDetail | irby | Carrier sub‐types |
GeneralLedger |
GeneralLedger | irby | GL accounts |
GLTypeDetail |
GLTypeDetail | irby | GL sub‐accounts |
Ticketing & Issue Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
Ticket |
Ticket | irby | Service/help desk |
Update |
Update | irby | Ticket history |
Issue |
Issue | irby | Reference issues table |
Time Tracking Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
TimeEntryType |
TimeEntryType | irby | Lookup table |
TimeSheetEntry |
TimeSheetEntry | irby | Daily hours worked |
Miscellaneous Entities
| Entity | Table | Schema | Notes |
|---|---|---|---|
CovidTestData |
CovidTestData | irby | COVID testing staging |
LytxTemplate |
LytxTemplate | irby | Telematics data |
Manufacturer |
AssetManufacturer | irby | Asset makes lookup |
OperatingSystem |
OperatingSystem | irby | OS reference for computers |
RequestOption |
RequestOption | irby | Support request items |
State |
State | irby | US states |
Vehicle |
Vehicle | irby | Fleet vehicles |
AssetHistory |
AssetHistory | irby | Asset action audit trail |
AssetModel |
AssetModel | irby | Asset model master |
AssetModelDetail |
AssetModelDetail | irby | Asset model options |
📈 Entity Relationship Diagram (UML)
classDiagram
Asset <|-- Computer
Asset <|-- DeskPhone
Asset <|-- Dock
Asset <|-- MobileDevice
Asset <|-- Monitor
Asset <|-- NetworkEquipment
Asset <|-- OfficePrinter
Asset <|-- Printer
Asset <|-- SafetyEquipment
Asset o-- FieldOffice : FieldOfficeId
Asset o-- AssetModel : ModelId
Asset o-- Employee : OwnerId
Computer o-- OperatingSystem : OperatingSystemId
SafetyEquipment o-- OperatingSystem : OperatingSystemId
Employee o-- Job : CurrentJobId
ODSEmployee o-- ODSJob : ORG_BU
Ticket o-- Update : TicketId
AssetModel o-- Manufacturer : MakeId
GLTypeDetail o-- GeneralLedger: GeneralLedgerId
🔗 Dependencies & Technologies
- .NET Target Framework: .NET 7.0
- Entity Framework Core: 7.0.7
- Database Provider: Microsoft.EntityFrameworkCore.SqlServer
- Tools:
dotnet efCLI- Visual Studio / VS Code
⚙️ Usage & Examples
Applying the Migration
# Apply all pending migrations
dotnet ef database update
Rolling Back
# Roll back to the previous migration
dotnet ef database update 20230701120000_PreviousMigration
Inspecting Model
You can view the generated model snapshot under:
IrbyImaging.DbContext/Migrations/20230711141837_RemoveHrColumns.Designer.cs
✅ Best Practices
- Keep Migrations Small & Focused
Group related schema changes into separate migrations (e.g., one for column removals, another for table additions). - Review Before Commit
Even though designer files are auto-generated, verify that your intended columns/tables are created or dropped. - Use Descriptive Migration Names
RemoveHrColumnsclearly states intent. Alternatives:AddInvoiceTable,RenameCustomerName. - Backup Production DB before applying migrations in critical environments.
🎯 Conclusion
This Designer file is a snapshot of your domain model after the RemoveHrColumns migration. It contains:
- Definitions for ~60 entities
- All keys, indices, table mappings, and TPH inheritance
- Relationship wiring for navigations and cascade rules
Use it to reliably synchronize your EF Core model with the SQL Server database. Happy coding! 🚀
Generated with ❤️ by your EF Core Migrations system.