📝 Table of Contents
- 📖 Overview & Purpose
- 🛠️ Key Functional Areas
- 📦 Dependencies & Technologies
- 🏷️ Data Models & Mappings
4.1. Asset Domain
4.2. Document Imaging Domain (Bidding)
4.3. Employee & Security Domain
4.4. Additional Domains (Billing, HR, etc.) - 🔗 Relationships & Navigation Properties
- ⚙️ Identity, Keys & Indices
- 🧩 Inheritance & Discriminators
- 💻 Sample
BuildTargetModelSnippets - 🚀 How to Use This Migration
- 🏁 Conclusion
📖 Overview & Purpose
The AddBiddingImaging.Designer.cs file is an auto‑generated snapshot of the EF Core model used by the AddBiddingImaging migration in the IrbyImaging.DbContext. Its primary roles are:
- 🎯 Capturing the target database schema after applying the migration.
- 🔄 Defining entities, properties, indices, relationships, and inheritance strategies.
- 🛡️ Ensuring EF Core can compare models for future migrations.
Note: You normally do not edit this file directly—it is regenerated whenever you scaffold a new migration.
🛠️ Key Functional Areas
- Model Configuration: Uses
ModelBuilderto configure every domain class. - Schema Mapping: Assigns tables to schemas (e.g.,
"irby"). - Entity Inheritance: Implements Table‑Per‑Hierarchy (TPH) for assets.
- Index & Key Setup: Defines primary keys (
HasKey) and indices (HasIndex). - New Bidding‑Imaging Support:
- Adds
IsBiddingflags. - Introduces
BiddingDocumentTypeGUID onDocumentImage.
- Adds
📦 Dependencies & Technologies
| Technology | Version | Purpose |
|---|---|---|
| .NET / C# | 7.0 | Language & runtime |
| Microsoft.EntityFrameworkCore | 7.0.7 | ORM |
| Microsoft.EntityFrameworkCore.SqlServer | 7.0.7 | SQL Server provider |
| EF Core Migrations | Built‑in | Database change tracking |
🏷️ Data Models & Mappings
Below is a high‑level look at some core domain entities configured in this migration.
4.1 Asset Domain
| Entity | Table (irby.Asset) |
Inheritance | Key |
|---|---|---|---|
Asset (base) |
Asset | TPH → Discriminator | Id : Guid |
Computer |
Asset | Discriminator = "Computer" | Id |
MobileDevice |
Asset | Discriminator = "MobileDevice" | Id |
SafetyEquipment |
Asset | Discriminator = "SafetyEquipment" | Id |
| … | … | … | … |
- Discriminator column (
Discriminator) differentiates subtypes. - TPH Mapping: All asset types in one table with subtype columns.
4.2 Document Imaging Domain (Bidding)
| Entity | Table (irby.DocumentImage) |
New Fields |
|---|---|---|
DocumentImage |
DocumentImage (schema irby) | IsBidding : bool |
BiddingDocumentType : Guid |
||
TempDocumentData |
TempDocumentData (schema irby) | IsBidding : bool |
DocumentCategory |
DocumentCategory (schema irby) | IsBidding : bool |
These properties surface the state of bidding‑specific documents:
IsBidding: Marks that an image/document belongs to the bidding workflow.BiddingDocumentType: Foreign key intoDocumentTypefor categorizing bidding docs.
4.3 Employee & Security Domain
| Entity | Table (irby.Employee) |
Key | Notes |
|---|---|---|---|
Employee |
Employee | EmployeeId : Guid |
Index on JdeNumber (unique). |
Role |
Role | RoleId : Guid |
— |
Permissions |
Permissions | PermissionId |
— |
LinkUserRole |
LinkUserRole (irby) | Composite FK | Many‑to‑many between Employee↔Role |
LinkRolePermission |
LinkRolePermission | Composite FK | Many‑to‑many between Role↔Permission |
4.4 Additional Domains (Billing, HR, etc)
- Billing:
BillingInvoicetable with charges & GL references. - HR: Timesheets (
HRTimeSheet,HREmployeeTimeEntry, …). - FieldOffice & Job: Geographical & job‑site mappings.
- Temporary Data:
TempDocumentData,BlobDatafor staging images.
🔗 Relationships & Navigation Properties
-
One‐to‐Many
FieldOffice→AssetsJob→EmployeesDocumentImage→AuditDetailviaDocumentImageId
-
Many‐to‐Many (via linking tables)
Employee↔Role(LinkUserRole)Role↔Permissions(LinkRolePermission)
-
Cascade Delete
- Deleting a
Jobcascades to itsEmployeesandPurchaseOrders. - Deleting a
DocumentType(accounting/bidding/HR etc.) cascades toDocumentImage.
- Deleting a
classDiagram
Asset <|-- Computer
Asset <|-- MobileDevice
DocumentImage *-- DocumentType : BiddingDocumentType
Role *-- Permissions : LinkRolePermission
Employee *-- Role : LinkUserRole
FieldOffice "1" o-- "*" Asset
Job "1" o-- "*" Employee
⚙️ Identity, Keys & Indices
- ValueGeneratedOnAdd
- Default GUID or int identity for primary keys.
- UseIdentityColumns
- SQL Server identity strategy for numeric keys.
- Indices
- Uniqueness on business fields (e.g.,
Employee.JdeNumber,FieldOffice.JdeNumber). - Navigation FKs are indexed for performant joins.
- Uniqueness on business fields (e.g.,
🧩 Inheritance & Discriminators
- Table‑Per‑Hierarchy (TPH) for the
Assethierarchy:modelBuilder.Entity<Asset>() .HasDiscriminator<string>("Discriminator") .HasValue<Asset>("Asset") .HasValue<Computer>("Computer") .HasValue<MobileDevice>("MobileDevice") .HasValue<SafetyEquipment>("SafetyEquipment"); - Subtypes share one table and pick up extra columns when needed.
💻 Sample BuildTargetModel Snippets
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "7.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// … Asset Definition
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b =>
{
b.Property<Guid>("Id").ValueGeneratedOnAdd();
b.Property<string>("Category").IsRequired();
b.Property<string>("Discriminator").IsRequired();
b.HasKey("Id");
b.HasIndex("FieldOfficeId");
b.ToTable("Asset", "irby");
b.HasDiscriminator<string>("Discriminator")
.HasValue("Asset");
});
// … DocumentImage Bidding Support
modelBuilder.Entity("IrbyImaging.DomainClasses.DocumentImage", b =>
{
b.Property<Guid>("DocumentImageId");
b.Property<bool>("IsBidding");
b.Property<Guid>("BiddingDocumentType");
b.HasKey("DocumentImageId");
b.ToTable("DocumentImage", "irby");
});
// … Temporary Staging
modelBuilder.Entity("IrbyImaging.DomainClasses.TempDocumentData", b =>
{
b.Property<Guid>("TempDocumentDataId").ValueGeneratedOnAdd();
b.Property<bool>("IsBidding");
b.HasKey("TempDocumentDataId");
b.ToTable("TempDocumentData", "irby");
});
// More entity configurations…
}
🚀 How to Use This Migration
- Scaffold a Migration
dotnet ef migrations add AddBiddingImaging - Review & Apply
dotnet ef database update - Verify Schema
- Check
irby.DocumentImagefor the newIsBiddingandBiddingDocumentTypecolumns. - Confirm
TempDocumentData.IsBiddingandDocumentCategory.IsBiddingexist.
- Check
🏁 Conclusion
This AddBiddingImaging.Designer.cs file represents the complete EF Core model snapshot after introducing bidding‑related imaging support. It:
- Extends DocumentImage and TempDocumentData with
IsBiddingand a foreign keyBiddingDocumentType. - Updates the DocumentCategory model to include
IsBidding. - Showcases comprehensive entity configurations, relations, inheritance, and indices across the
irbyschema.
With this migration applied, the database schema is ready to capture and classify bidding documents alongside existing accounting, HR, and safety workflows. 🚀
🎉 Happy Coding! 🎉