📄 UpdateEmployeeTableWithNewColumnsWithNewColumns2.Designer.cs
Path:
IrbyImaging.DbContext/Migrations/20240201183732_UpdateEmployeeTableWithNewColumns2.Designer.cs
Auto-generated: Yes
Purpose: EF Core migration model snapshot for UpdateEmployeeTableWithNewColumns2
📑 Table of Contents
- 📝 Overview & Purpose
- ⚙️ Key Functional Areas
- 🔗 Dependencies & Technologies
- 💾 Data Models Overview
- 🔍 Helper Methods & Utilities
- 🚫 Error Handling & Return Types
- 🌐 API Endpoints Overview
- 🔌 Third‑party Integrations
- 🛠 Usage Examples
- 🏁 Conclusion
📝 Overview & Purpose
This Designer file is part of Entity Framework Core migrations. It provides a snapshot of the Irb yContext model at the moment when the migration UpdateEmployeeTableWithNewColumns2 was added. EF Core uses this snapshot to:
- Understand the current shape of your database schema
- Compare it against previous snapshots to generate Up/Down scripts
- Support commands like
dotnet ef database update
🚨 Warning:
This file is auto-generated by the EF Core Tools. Do not modify it manually. Changes will be overwritten on the nextAdd-Migration.
⚙️ Key Functional Areas
EF Core Migrations
- [DbContext(typeof(IrbyContext))]: Associates this snapshot with the
IrbyContext. - [Migration("20240201183732_UpdateEmployeeTableWithNewColumns2")]: Names the migration and stamps it with a timestamp.
[DbContext(typeof(IrbyContext))]
[Migration("20240201183732_UpdateEmployeeTableWithNewColumns2")]
partial class UpdateEmployeeTableWithNewColumns2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// ← The heart of the snapshot
}
}
BuildTargetModel Method
- Signature:
protected override void BuildTargetModel(ModelBuilder modelBuilder) - Populates the
ModelBuilderwith every entity, property, key, index, discriminator, relationship, and table mapping. - Called internally by EF Core at design‑time and runtime to reconstruct your model.
ModelBuilder Annotations & Defaults
- Product Version
modelBuilder.HasAnnotation("ProductVersion", "7.0.7"); - Max Identifier Length (SQL Server default)
.HasAnnotation("Relational:MaxIdentifierLength", 128); - Identity Columns
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
Entity Configurations
For each domain class, the designer configures:
- Properties (with types, nullability)
- Keys (
.HasKey(...)) - Indices (
.HasIndex(...)) - Table Names & Schemas (
.ToTable("Name", "Schema"))
Sample: Employee Entity
| Aspect | Configuration Example |
|---|---|
| Primary Key | b.HasKey("EmployeeId"); |
| Table + Schema | b.ToTable("Employee", "irby"); |
| Column & Type | b.Property<string>("JdeNumber").HasColumnType("nvarchar(450)"); |
| Required Fields | b.Property<string>("Status").IsRequired() |
| Unique Index | b.HasIndex("JdeNumber").IsUnique().HasFilter("[JdeNumber] IS NOT NULL"); |
modelBuilder.Entity("IrbyImaging.DomainClasses.Employee", b => {
b.Property<Guid>("EmployeeId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("JdeNumber")
.HasColumnType("nvarchar(450)");
b.HasKey("EmployeeId");
b.HasIndex("JdeNumber")
.IsUnique()
.HasFilter("[JdeNumber] IS NOT NULL");
b.ToTable("Employee","irby");
});
Inheritance & Discriminators
Table‑per‑Hierarchy (TPH) is used for the Asset base class and its subtypes:
- Base Entity:
IrbyImaging.DomainClasses.Asset - Discriminator Column:
Discriminator - Sub‑types:
Computer,DeskPhone,Dock,MobileDevice,Monitor,NetworkEquipment,OfficePrinter,Printer,SafetyEquipment
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
b.HasDiscriminator<string>("Discriminator")
.HasValue("Asset");
});
modelBuilder.Entity("IrbyImaging.DomainClasses.Computer", b => {
b.HasBaseType("IrbyImaging.DomainClasses.Asset");
b.HasDiscriminator().HasValue("Computer");
b.ToTable("Asset","irby");
});
Relationships & Navigations
Each foreign‑key association is configured via HasOne/WithMany/HasForeignKey:
| Principal Entity | Navigation | Dependent FK |
|---|---|---|
Asset ↔ FieldOffice |
Asset.FieldOffice |
FieldOfficeId |
AssetModel ↔ Manufacturer |
AssetModel.Make |
MakeId |
Employee ↔ Department |
Employee.Department |
DepartmentId |
TimeSheetEntry ↔ Employee |
TimeSheetEntry.Employee |
EmployeeId |
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset", b => {
b.HasOne("IrbyImaging.DomainClasses.FieldOffice","FieldOffice")
.WithMany("Assets")
.HasForeignKey("FieldOfficeId");
});
🔗 Dependencies & Technologies
- .NET 7.0
- EntityFrameworkCore 7.0.7
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Tools
- C# 10.0
💾 Data Models Overview
This Designer file lists all domain entities and their schema mappings.
Below is a non‑exhaustive list of key tables covered:
| Entity | Schema | Table |
|---|---|---|
Asset |
irby | Asset |
Employee |
irby | Employee |
FieldOffice |
irby | FieldOffice |
Job |
irby | Job |
Department |
irby | Department |
AssetModel, Manufacturer |
irby | AssetModel, AssetManufacturer |
TimeSheetEntry, TimeEntryType |
irby | TimeSheetEntry, TimeEntryType |
| … (many more) |
🔍 Helper Methods & Utilities
- ModelBuilder Extensions:
UseIdentityColumns()UseIdentityColumn()on specific properties
- Pragma Directives:
#pragma warning disable 612, 618- Suppresses warnings about obsolete API usage.
🚫 Error Handling & Return Types
N/A
This file solely declares metadata—no runtime logic, error handling, or return‑type considerations are present.
🌐 API Endpoints Overview
N/A
This migration snapshot does not expose web/API endpoints.
🔌 Third‑party Integrations
- SQL Server via
Microsoft.EntityFrameworkCore.SqlServer - Value Conversion utilities from
Microsoft.EntityFrameworkCore.Storage.ValueConversion
🛠 Usage Examples
- Add a New Migration
dotnet ef migrations add UpdateEmployeeTableWithNewColumns2 - Update the Database
dotnet ef database update - View the Snapshot
- Inspect this Designer file to see the full model
- Compare with previous snapshots in
Migrations/
Sample: Extending the Model
If you add a new property to Employee:
public class Employee {
public string MiddleName { get; set; } // Existing
public string EmergencyContact { get; set; } // NEW
}
Then:
dotnet ef migrations add AddEmergencyContactToEmployee
dotnet ef database update
A new Designer snapshot will include:
b.Property<string>("EmergencyContact")
.HasColumnType("nvarchar(max)");
🏁 Conclusion
This Designer file is a comprehensive, auto‑generated blueprint of your EF Core model at the time of the UpdateEmployeeTableWithNewColumns2 migration. It ensures that migrations remain consistent, reproducible, and provides a point‑in‑time reference of your database schema. Always rely on EF Core Tools to regenerate it—never edit manually.
Happy coding! 🚀