📄 Documentation: 20220608152519_MoreColumnsForLegalImaging.Designer.cs
File Path:
IrbyImaging.DbContext/Migrations/20220608152519_MoreColumnsForLegalImaging.Designer.csAssembly:
IrbyImaging.DbContext
Author: kvamshi
Created/Modified: 06‑08‑2022
📑 Table of Contents
- Introduction
- Purpose & Overview
- EF Core Migrations at a Glance
- File Structure & Key Attributes
BuildTargetModelMethod Deep Dive- Entities & Data Models
- Relationships & Fluent API Configuration
- Key Changes in This Migration
- How to Apply & Use This Migration
- Mermaid UML Diagram
- Conclusion
1. Introduction
Welcome to the generated snapshot of MoreColumnsForLegalImaging—an Entity Framework Core (EF Core) migration designer file. This file contains the complete model definition as of the 20220608152519 migration. It is auto‑generated by EF Core to support database schema changes while preserving model compatibility.
2. Purpose & Overview
✨ Purpose:
- Provide a model snapshot that EF Core uses to compute differences between your C# domain classes and the target database schema.
- Ensure that subsequent migrations can build upon this exact state of the model.
🔍 Overview:
- Defines all entity types, their properties, keys, indices, table mappings, discriminators (for TPH inheritance), and relationships.
- Critical for supporting the
Up()andDown()methods found in the corresponding.csmigration file.
3. EF Core Migrations at a Glance
- Migrations track incremental changes to your model.
- A migration typically consists of:
<timestamp>_MoreColumnsForLegalImaging.cs→ Contains Up() / Down() to apply or revert schema changes.<timestamp>_MoreColumnsForLegalImaging.Designer.cs→ Contains BuildTargetModel() with the model snapshot.
👍 Why the Designer file matters:
- Model Consistency
- Future Diffs
- Scaffolding
4. File Structure & Key Attributes
[DbContext(typeof(IrbyContext))]
[Migration("20220608152519_MoreColumnsForLegalImaging")]
partial class MoreColumnsForLegalImaging : Migration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// ... fluent configuration ...
}
}
[DbContext(typeof(IrbyContext))]
Associates this migration with theIrbyContext.[Migration("20220608152519_MoreColumnsForLegalImaging")]
Uniquely identifies the migration by timestamp and name.partial class MoreColumnsForLegalImaging : Migration
Extends EF Core’sMigrationbase type.
5. BuildTargetModel Method Deep Dive
The heart of this file is the fluent configuration of your entire domain model:
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.12")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// Example: Asset entity
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Category")
.IsRequired()
.HasColumnType("nvarchar(max)");
// ... other Asset properties ...
b.HasKey("Id");
b.ToTable("Asset", "irby");
b.HasDiscriminator<string>("Discriminator").HasValue("Asset");
});
- Global Annotations:
MaxIdentifierLength(128)- EF Core
ProductVersion - SQL Server identity strategy
- Entity Definitions:
- Properties: Data types, nullability, length
- Keys: Primary keys via
HasKey(...) - Indices:
HasIndex(...) - Table & Schema Mapping:
ToTable("Name","Schema") - Inheritance Mapping:
HasDiscriminator<T>("...")
6. Entities & Data Models
Below is a simplified list of core entities introduced or modified in this snapshot:
| Entity | Table (Schema) | PK | Notes |
|---|---|---|---|
| Asset | irby.Asset | Id (GUID) | TPH base for IT assets |
| ├─ Computer | irby.Asset | Id | + AssetNumber, OperatingSystemId |
| ├─ MobileDevice | irby.Asset | Id | + Imei (unique), Carrier |
| ├─ DeskPhone, Printer, etc. | irby.Asset | Id | Various discriminators |
| AssetModel | irby.AssetModel | Id (int) | FK → Manufacturer |
| AssetModelDetail | dbo.AssetModelDetail | Id (int) | FK → AssetModel, Make |
| FieldOffice | irby.FieldOffice | Id (GUID) | Relationships to Employee |
| Employee | irby.Employee | Id (GUID) | Unique Index on JdeNumber |
| Job | irby.Job | Id (GUID) | Unique Index on JdeNumber |
| DocumentImage | irby.DocumentImage | DocumentImageId (GUID) | NEW columns for legal imaging |
| … and many more (Tickets, Updates, CovidTestData, etc.) |
ℹ️ Tip: The full code lists 40+ entities. Use your IDE’s Go To Definition to explore each.
7. Relationships & Fluent API Configuration
🔗 Key Foreign Keys
| Principal Entity | Navigation Property | Dependent Entity | FK Field | OnDelete |
|---|---|---|---|---|
| AssetModel → Make | Make |
AssetModel | MakeId | Cascade |
| Asset → Model | Model |
Asset | ModelId | Cascade |
| Asset → Owner | Owner |
Asset | OwnerId | (no cascade) |
| Employee → Job | CurrentJob |
Employee | CurrentJobId | Cascade |
| DocumentImage | (no nav) | (flat properties) | – | – |
| Ticket → Updates | Updates |
Update | TicketId | Cascade |
🛠️ Navigations
After properties & keys, the designer file wires up navigation properties:
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
b.HasOne("IrbyImaging.DomainClasses.FieldOffice", "FieldOffice")
.WithMany("Assets")
.HasForeignKey("FieldOfficeId");
// …
b.Navigation("FieldOffice");
b.Navigation("Model");
b.Navigation("Owner");
});
8. Key Changes in This Migration
While the Designer file is a snapshot—not the diffs—the migration name suggests “More Columns For Legal Imaging.” Likely additions include:
- DocumentImage
DocumentCategory(nvarchar)DocumentNotes(nvarchar)DocumentType(nvarchar)OriginalReferenceId(GUID)TotalPages,Pagefields (int)
These enable capturing additional metadata for legal imaging workflows.
9. How to Apply & Use This Migration
- Add the Migration (already done):
dotnet ef migrations add MoreColumnsForLegalImaging - Update Database:
dotnet ef database update 20220608152519_MoreColumnsForLegalImaging - In Code:
using (var context = new IrbyContext()) { context.Database.Migrate(); // Now you can CRUD DocumentImage with the new columns: var doc = new DocumentImage { FileName = "contract.pdf", DocumentCategory = "Legal", DocumentNotes = "Signed by counsel", // … }; context.Add(doc); context.SaveChanges(); }
10. Mermaid UML Diagram
classDiagram
Asset <|-- Computer
Asset <|-- MobileDevice
Asset <|-- DeskPhone
Asset <|-- Printer
Asset <|-- OfficePrinter
Asset <|-- Monitor
Asset <|-- NetworkEquipment
Asset <|-- SafetyEquipment
AssetModel --> Manufacturer : Make
AssetModel --> AssetModelDetail : AssetsModelDetail
Asset --> AssetHistory : AssetHistories
Employee --> Job : CurrentJob
FieldOffice --> Employee : Manager, ProjectManager, Superintendent
Ticket --> Update : Updates
11. Conclusion
This Designer file is a structural blueprint of your EF Core model at the point when MoreColumnsForLegalImaging was created. It:
- Ensures reliable diffs for future migrations.
- Captures all entities, properties, keys, indices, and relationships.
- Reflects new legal‑imaging metadata columns for DocumentImage.
⚠️ Do not manually edit this file—let EF Core manage it. For schema changes, modify your domain classes and generate a new migration.
Happy coding! 🚀