🗂️ Migration Documentation: UpdateAttributeList.Designer.cs
File:
IrbyImaging.DbContext/Migrations/20220803204201_UpdateAttributeList.Designer.cs
Purpose: Auto‑generated Entity Framework Core migration designer file that defines the target model snapshot for theUpdateAttributeListmigration.
EF Core Version: 5.0.12
Schema: All tables live in theirbyschema (unless otherwise noted).
📋 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Key Functional Areas
- Data Models & Entities
- Relationships & Navigation
- Using the Migration
- Sample Code Snippets
- UML Entity‑Relationship Diagram
- Conclusion
🔍 Overview & Purpose
This designer file is part of the Entity Framework Core Migrations infrastructure. Its main role is to:
- Capture the entire shape of your EF Core model—entities, properties, keys, relationships—at the moment the
UpdateAttributeListmigration was scaffolded. - Support EF Core tools when generating SQL (
Update-Database) or diffing future migrations. - Serve as a readonly “snapshot”—do not manually edit.
⚙️ Dependencies & Technologies
| Technology / Package | Version / Role |
|---|---|
| Microsoft.EntityFrameworkCore | 5.0.12 (Model building & Migrations) |
| Microsoft.EntityFrameworkCore.SqlServer | Underlying SQL Server provider |
| Microsoft.EntityFrameworkCore.Migrations | Migrations API |
| Microsoft.EntityFrameworkCore.Storage.ValueConversion | Value converters support |
| .NET / C# | Language & runtime |
🔑 Key Functional Areas
- Global Annotations
Sets up model‐wide metadata:modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("ProductVersion", "5.0.12") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - Entities Configuration
For each domain class, fluent API configures:- Table & Schema (
.ToTable("Name","irby")) - Properties (
.Property<>()…HasColumnType(...)) - Keys (
.HasKey(...)) - Indexes (
.HasIndex(...)) - Discriminator for TPH inheritance
- Table & Schema (
- Relationships
Defines foreign keys and navigations via:b.HasOne(...).WithMany(...).HasForeignKey(...).OnDelete(...); b.Navigation(...);
📊 Data Models & Entities
Below is a high‐level summary of the main entities declared in this migration snapshot:
| Entity | Table | PK Type | Notes |
|---|---|---|---|
| Asset | Asset (irby) |
Guid |
TPH base; Discriminator required |
| AssetHistory | AssetHistory (irby) |
Guid |
Tracks asset changes |
| AssetModel | AssetModel (irby) |
int |
Links to Manufacturer |
| AssetModelDetail | AssetModelDetail |
int |
Optional per‐model config |
| DocumentAttribute | DocumentAttribute |
Guid |
Updated list of document metadata attributes |
| DocumentCategory | DocumentCategory (irby) |
Guid |
Document taxonomy |
| DocumentImage | DocumentImage (irby) |
Guid |
Binary blobs + OCR text |
| DocumentType | DocumentType (irby) |
Guid |
Classification of documents |
| Employee | Employee (irby) |
Guid |
Includes unique JDE number |
| FieldOffice | FieldOffice (irby) |
Guid |
Links to multiple managers |
| ... | ... | ... | More domain classes (Job, Ticket, Update, etc.) |
⭐ Focus: DocumentAttribute
| Property | CLR Type | DbType | Description |
|---|---|---|---|
| Id | Guid |
uniqueidentifier |
Primary Key (Add on Insert) |
| AttributeName | string |
nvarchar(max) |
Name of the attribute |
| AttributeType | int |
int |
Enum / code defining data type |
| DocumentType | string |
nvarchar(max) |
Which doc type the attribute applies to |
| IsMultiValue | bool |
bit |
Allows multiple values? |
| IsRequired | bool |
bit |
Mandatory at data entry? |
| LinkEmployeeData | bool |
bit |
Auto‐link to employee table? |
| Values | string |
nvarchar(max) |
Serialized list of allowed values |
| AddedBy / Date | string / DateTime |
datetime2 |
Audit fields |
| ModifiedBy / Date | string / DateTime |
datetime2 |
Audit fields |
🔗 Relationships & Navigation
- Asset → AssetModel: Required many‐to‐one
- Asset → FieldOffice: Optional many‐to‐one
- Employee → Job: Required many‐to‐one
- CarrierType → CarrierTypeDetail: One‐to‐many
- Ticket → Update: One‐to‐many
- TPH Inheritance on
Asset:Computer,MobileDevice,DeskPhone,OfficePrinter, etc.- Differentiated by
.HasDiscriminator("Discriminator").
🛠️ Using the Migration
1. Scaffold a Migration
Add-Migration UpdateAttributeList
2. Review & Adjust
- EF generated this
.Designer.csand a matching.csthat containsUp()/Down()methods. - Do not modify the designer file.
3. Apply to Database
Update-Database
💻 Sample Code Snippets
Fluent API: Entity Configuration
modelBuilder.Entity("IrbyImaging.DomainClasses.DocumentAttribute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("AttributeName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("AttributeType")
.HasColumnType("int");
b.Property<string>("Values")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DocumentAttribute", "irby");
});
TPH Discriminator
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b =>
{
b.HasDiscriminator<string>("Discriminator")
.HasValue("Asset");
});
modelBuilder.Entity("IrbyImaging.DomainClasses.Computer")
.HasBaseType("IrbyImaging.DomainClasses.Asset")
.HasDiscriminator().HasValue("Computer");
🖼️ UML Entity‑Relationship Diagram
erDiagram
ASSET ||--o{ ASSET_HISTORY : "history records"
ASSET }|--|{ ASSETMODELDETAIL : "model details"
ASSET ||--o{ UPDATE : "ticket updates"
EMPLOYEE ||--o{ ASSET : "owns"
FIELD_OFFICE ||--o{ ASSET : "hosts"
TICKET ||--o{ UPDATE : "has"
ASSET }|--|{ COMPUTER : "TPH subtype"
ASSET }|--|{ MOBILEDEVICE : "TPH subtype"
CARRIERTYPE ||--o{ CARRIERTYPEDETAIL : "details"
✅ Conclusion
This designer file is a critical part of the EF Core Migrations system. It provides a complete snapshot of your model at the point of the UpdateAttributeList migration:
- Ensures consistency when generating SQL.
- Captures TPH inheritance, properties, keys, indexes, and relationships.
- Acts as a reference for any future migrations.
Tip: Always keep migrations under source control—and never hand‑edit the
.Designer.csfiles.
Happy coding! 🚀