📑 Documentation: AddNewColumnsBilling.Designer.cs
Welcome to the comprehensive documentation for the Entity Framework Core migration designer file
IrbyImaging.DbContext/Migrations/20230629190543_AddNewColumnsBilling.Designer.cs.
This auto‑generated file captures the target data model after applying the AddNewColumnsBilling migration.
📖 Table of Contents
- Overview & Purpose
- Migration Context
- Key Functional Areas
- Dependencies & Technologies
- Data Models (Entities)
- BuildTargetModel Method
- UML Diagram (ER Sample)
- Using the Migration
- Helper Methods & Utilities
- Error Handling & Return Types
- API Endpoints Overview
- Third‑party Integrations
- Sample Code Blocks & Usage Examples
- Conclusion
1. Overview & Purpose
AddNewColumnsBilling.Designer.cs is an auto‑generated EF Core designer file that describes the target database schema after executing the 20230629190543_AddNewColumnsBilling migration.
- ✋ Do not edit manually; it is maintained by EF Core.
- 🤝 Works alongside the migration class
AddNewColumnsBilling.cs(which containsUp()/Down()methods). - 🎯 Ensures EF Core can compute future diffs and scaffold new migrations correctly.
2. Migration Context
- Migration Name:
20230629190543_AddNewColumnsBilling - DbContext:
IrbyContext - EF Core Version: 7.0.7
- Provider: Microsoft SQL Server
This migration likely adds new billing-related columns to the BillingInvoice table, such as:
Charge(decimal)GeneralLedgerId(GUID FK)InvoiceYearMonth(string)IsDeleted(soft‑delete flag)JDENumber,JobNumber,JobName(job tracking)
3. Key Functional Areas
This file’s BuildTargetModel method configures all entities in the IrbyImaging.DomainClasses namespace, covering:
| Domain Area | Entities (Tables) |
|---|---|
| 🖥 Asset & Inventory | Asset, AssetHistory, AssetModel, AssetModelDetail, Computer, DeskPhone, … |
| 💰 Billing & Finance | BillingInvoice, CarrierType, CarrierTypeDetail, GeneralLedger, GLTypeDetail |
| 📂 Document Management | BlobData, DocumentAttribute, DocumentCategory, DocumentImage, DocumentType, … |
| 👥 Employees & Jobs | Employee, Job, ODSEmployee, ODSJob, FieldOffice, Issue, Ticket, Update |
| 🔧 Miscellaneous | Customer, CovidTestData, RequestOption, State, Vehicle, LytxTemplate, … |
Note: Migrations may affect only a subset (here, Billing), but the designer enumerates all entities for a complete model snapshot.
4. Dependencies & Technologies
- .NET 7
- Entity Framework Core 7 (Microsoft.EntityFrameworkCore)
- SQL Server (Microsoft.EntityFrameworkCore.SqlServer)
- Value Conversion & Identity Columns (
UseIdentityColumns,UseIdentityColumn)
5. Data Models (Entities)
Below is a high‑level grouping of data models configured in this migration.
5.1 Asset & Inventory
| Entity | Table (Schema) | Key Properties / Notes |
|---|---|---|
| Asset | irby.Asset | PK: Id (GUID); TPH base for all assets |
| AssetHistory | irby.AssetHistory | PK: Id; FK: AssetId |
| AssetModel | irby.AssetModel | PK: Id (INT); FK: MakeId |
| AssetModelDetail | AssetModelDetail | PK: Id; FK: AssetModelId, MakeId |
| Computer | irby.Asset | Inherits Asset; + AssetNumber, CpsNumber, OperatingSystemId |
| DeskPhone | irby.Asset | Inherits Asset; + MacAddress, PhoneNumber |
| MobileDevice | irby.Asset | Inherits Asset; + Carrier, Imei (unique), PhoneNumber |
| Monitor, Printer, Dock, NetworkEquipment, OfficePrinter, SafetyEquipment | irby.Asset | Inherit Asset, add specialized properties |
5.2 Billing & Finance
| Entity | Table (Schema) | Key Properties |
|---|---|---|
| BillingInvoice | irby.BillingInvoice | PK: Id (GUID); Charge, GeneralLedgerId (FK); invoice metadata |
| CarrierType | irby.CarrierType | PK: Id; Carrier, IsInactive |
| CarrierTypeDetail | irby.CarrierTypeDetail | PK: Id; FK: CarrierTypeId |
| GeneralLedger | irby.GeneralLedger | PK: Id; Code, Description |
| GLTypeDetail | GLTypeDetail | PK: Id; FK: GeneralLedgerId |
5.3 Document Management
| Entity | Table (Schema) | Key Properties |
|---|---|---|
| BlobData | irby.BlobData | PK: BlobDataId; ImageContents |
| DocumentAttribute | irby.DocumentAttribute | PK: Id; AttributeName, IsRequired |
| DocumentCategory | irby.DocumentCategory | PK: Id; Name, IsDeleted |
| DocumentType | irby.DocumentType | PK: Id; Type, IsAvailable |
| DocumentImage | irby.DocumentImage | PK: DocumentImageId; OCR fields |
| TempDocumentData | irby.TempDocumentData | PK: TempDocumentDataId; staging data |
| IrbyForms | irby.IrbyForms | PK: FormId |
| IPMMigration | irby.IPMMigration | PK: IPMMigrationId |
5.4 Employees & Jobs
| Entity | Table (Schema) | Key Properties |
|---|---|---|
| Employee | irby.Employee | PK: Id; JdeNumber (unique); FK: CurrentJobId |
| Job | irby.Job | PK: Id; JdeNumber (unique) |
| FieldOffice | irby.FieldOffice | PK: Id; JdeNumber (unique); FKs: Manager/ProjectManager/Superintendent |
| ODSEmployee | irby.ODS_Employee_Staging | PK: EMPLOYEE_NUMBER; alt key: ORG_BU |
| ODSJob | irby.ODS_Jobs_Staging | PK: ORG_BU |
| Ticket | irby.Ticket | PK: Id; TicketNumber, Status |
| Update | irby.Update | PK: Id; FK: TicketId |
| Issue | irby.Issue | PK: Id |
5.5 Miscellaneous Entities
| Entity | Table (Schema) | Key Properties |
|---|---|---|
| Customer | irby.Customer | PK: Id; CustomerNumber |
| CovidTestData | irby.CovidTestData | PK: CovidTestDataId; test results |
| RequestOption | irby.RequestOption | PK: Id; Item, Type, Cost |
| State | irby.State | PK: Id; Code, Name, Abbreviation |
| Vehicle | irby.Vehicle | PK: Id; VehicleId |
| LytxTemplate | irby.LytxTemplate | PK: Id; telematics batch data |
| Manufacturer | irby.AssetManufacturer | PK: Id; Name, WarrantyMonths |
| OperatingSystem | irby.OperatingSystem | PK: Id; Name |
6. BuildTargetModel Method
All entity configurations are driven by the single method:
protected override void BuildTargetModel(ModelBuilder modelBuilder)
EF Core invokes this to capture the complete model after the migration.
6.1 Annotations & Configuration
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
- ProductVersion: EF Core 7.0.7
- MaxIdentifierLength: SQL Server limit (128 chars)
- UseIdentityColumns: Configures
IDENTITYfor integer PKs by default.
6.2 Entity Configuration Example: BillingInvoice
modelBuilder.Entity("IrbyImaging.DomainClasses.BillingInvoice", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("AddedBy").HasColumnType("nvarchar(max)");
b.Property<DateTime>("AddedDate").HasColumnType("datetime2");
b.Property<Guid>("CarrierId").HasColumnType("uniqueidentifier");
b.Property<string>("CarrierName").HasColumnType("nvarchar(max)");
b.Property<decimal>("Charge").HasColumnType("decimal(18,2)");
b.Property<string>("EmployeeName").HasColumnType("nvarchar(max)");
b.Property<string>("FileName").HasColumnType("nvarchar(max)");
b.Property<string>("FirstName").HasColumnType("nvarchar(max)");
b.Property<Guid>("GeneralLedgerId").HasColumnType("uniqueidentifier");
b.Property<string>("InvoiceYearMonth").HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted").HasColumnType("bit");
b.Property<string>("JDENumber").HasColumnType("nvarchar(max)");
b.Property<string>("JobName").HasColumnType("nvarchar(max)");
b.Property<string>("JobNumber").HasColumnType("nvarchar(max)");
b.Property<string>("LastName").HasColumnType("nvarchar(max)");
b.Property<string>("ModifiedBy").HasColumnType("nvarchar(max)");
b.Property<DateTime>("ModifiedDate").HasColumnType("datetime2");
b.Property<string>("PhoneNumber").HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("BillingInvoice", "irby");
});
- Charge: Stores invoice amount (precision 18,2).
- GeneralLedgerId: FK to
GeneralLedger(finance mapping). - IsDeleted: Soft‑delete flag for archival.
- InvoiceYearMonth: Denormalized period grouping (e.g.,
"2023-06"). - Additional metadata: JDE number, job details.
6.3 Relationships & Navigation Properties
The bottom section wires up relationships:
modelBuilder.Entity("IrbyImaging.DomainClasses.BillingInvoice", b =>
{
b.HasOne("IrbyImaging.DomainClasses.GeneralLedger", null)
.WithMany("GLTypeDetail") // example
.HasForeignKey("GeneralLedgerId");
});
Similar fluent API calls configure:
- 1‑to‑many (e.g.,
Asset→AssetHistory) - Self‑referencing (none here)
- TPH inheritance for
Assetdiscriminators (Computer,DeskPhone, etc.)
7. UML Diagram (ER Sample)
Below is a Mermaid ER diagram snippet illustrating BillingInvoice and its link to GeneralLedger:
erDiagram
BILLINGINVOICE {
GUID Id PK
decimal Charge
string InvoiceYearMonth
GUID GeneralLedgerId FK
bool IsDeleted
}
GENERALLEDGER {
GUID Id PK
string Code
string Description
}
BILLINGINVOICE }o--|| GENERALLEDGER : "belongs to"
This is a partial ER for clarity. The full model contains 40+ entities.
8. Using the Migration
- Add Migration
dotnet ef migrations add AddNewColumnsBilling - Update Database
dotnet ef database update - Inspect Model Snapshot
BuildTargetModelis executed to verify DB → Model consistency.
9. Helper Methods & Utilities
- SqlServerModelBuilderExtensions.UseIdentityColumns
- SqlServerPropertyBuilderExtensions.UseIdentityColumn
- ValueGeneratedOnAdd(), HasColumnType(), HasDiscriminator()
These methods unify column conventions (SQL Server identities, types, inheritance).
10. Error Handling & Return Types
- Error Handling: None in designer.
- Return Type:
voidforBuildTargetModel. - Exceptions: EF Core may throw if model inconsistent or provider missing.
11. API Endpoints Overview
❌ Not applicable — This is a data layer migration; there are no web/API endpoints here.
12. Third‑party Integrations
- Entity Framework Core (ORM)
- Microsoft SQL Server provider
13. Sample Code Blocks & Usage Examples
Querying the Updated Model
using var context = new IrbyContext();
// Fetch active invoices for June 2023
var juneInvoices = await context.Set<BillingInvoice>()
.Where(inv => inv.InvoiceYearMonth == "2023-06" && !inv.IsDeleted)
.Include(inv => inv.GeneralLedger)
.ToListAsync();
Adding a New Invoice
var invoice = new BillingInvoice
{
AddedBy = "jdoe",
AddedDate = DateTime.UtcNow,
CarrierId = Guid.NewGuid(),
CarrierName = "FastTrans Ltd.",
Charge = 1250.50m,
FirstName = "Jane",
LastName = "Doe",
GeneralLedgerId = glAccountId,
InvoiceYearMonth = "2023-06",
IsDeleted = false
};
context.BillingInvoices.Add(invoice);
await context.SaveChangesAsync();
14. Conclusion
This designer file is a read‑only snapshot of your EF Core model post‑migration. It:
- Enumerates every entity, property, and relationship.
- Ensures future migrations can compute diffs against the current schema.
- Should remain untouched; all changes belong in your code‑first domain or migration scripts.
🎉 With this migration applied, your BillingInvoice table is enriched to support detailed billing, soft deletes, and financial integration via a GeneralLedger lookup. Use the above examples to query and manipulate your new schema effectively!