📄 IrbyImaging.DbContext/Migrations/20250401134745_AddDeletedColumnJobClass.Designer.cs
Auto-generated EF Core migration snapshot
This designer file represents the model snapshot for theAddDeletedColumnJobClassmigration. It captures the state of your EF Core model (entities, properties, relationships, annotations) after this migration has been applied.
📑 Table of Contents
- 🎯 Overview & Purpose
- 🚀 Key Functional Areas
- 🔗 Dependencies & Technologies
- 🧩 Entities & Model Snapshot
- 🌐 Relationships & Navigation
- ⚙️ How EF Uses This File
- 👨💻 Usage Examples
- 🛠️ Common Migration Commands
- 📊 UML Diagram
- 📝 Conclusion
🎯 Overview & Purpose
When you run:
dotnet ef migrations add AddDeletedColumnJobClass
Entity Framework Core scaffolds two files:
20250401134745_AddDeletedColumnJobClass.cs
Contains theUp()/Down()methods to apply or rollback schema changes.20250401134745_AddDeletedColumnJobClass.Designer.cs
ContainsBuildTargetModel(ModelBuilder)which captures the entire EF model after yourUp()changes.
Why?
- EF Core needs a “snapshot” of your model at each migration to compute diffs when you add future migrations.
- You should not edit the designer file manually; it’s auto‐generated by the tooling.
🚀 Key Functional Areas
| Section | Responsibility |
|---|---|
DbContext Attribute |
[DbContext(typeof(IrbyContext))] ties this migration to your IrbyContext. |
Migration Attribute |
[Migration("20250401134745_AddDeletedColumnJobClass")] names this snapshot. |
BuildTargetModel |
Defines all entities, properties, keys, indexes, relationships & maps them to database tables. |
| Identity Configuration | UseIdentityColumns() instructs SQL Server to use identity (auto‐increment) columns. |
| Annotations | .HasAnnotation("ProductVersion","9.0.0"), .HasAnnotation("Relational:MaxIdentifierLength",128) |
// Example snippet from BuildTargetModel:
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("IrbyImaging.DomainClasses.Job", b => {
b.Property<Guid>("JobId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Name").HasColumnType("nvarchar(max)");
b.HasKey("JobId");
b.ToTable("Job","irby");
});
#pragma warning restore 612, 618
🔗 Dependencies & Technologies
- .NET 7+ / EF Core 9.0.0
- Microsoft.EntityFrameworkCore.SqlServer provider
- Microsoft.EntityFrameworkCore.Tools (for CLI)
- SQL Server
- C# 11 (nullable reference annotations disabled
#nullable disable)
🧩 Entities & Model Snapshot
This migration snapshot defines 100+ entities under the IrbyImaging.DomainClasses namespace. Below is a representative subset:
| Entity | Table (Schema) | Key | Notes |
|---|---|---|---|
| AccountBalances | irby.AccountBalances |
AccountBalanceId (GUID) |
Cost/revenue reporting per job |
| Job | irby.Job |
JobId (GUID) |
Core project/job data |
| JobClassification | irby.JobClassification |
JobClassificationId (GUID) |
Added IsDeleted column in this migration |
| Crew | irby.Crew |
CrewId (GUID) |
Field‐timesheet crew grouping |
| Employee | irby.Employee |
EmployeeId (GUID) |
Has unique JDE number index |
| FieldTimesheet | irby.FieldTimesheet |
TimesheetId (GUID) |
Identity column: TimesheetNumber |
| WorkEntry | irby.WorkEntry |
WorkEntryId (GUID) |
Navigation to EmployeeTimesheet |
| Asset (and derived types) | irby.Asset |
Id (GUID) |
TPH with discriminator (Computer, Monitor, etc.) |
| DocumentImage | irby.DocumentImage |
DocumentImageId (GUID) |
Imaging metadata & binary contents |
| …and many more… |
🚩 Tip: Your migration only needs to track changes in your code‐first model. The snapshot file holds everything to enable incremental migrations.
🌐 Relationships & Navigation
EF Core maps relationships via HasOne–WithMany and navigations:
- One‐to‐Many
modelBuilder.Entity("CrewEmployee", b => { b.HasOne("Crew") .WithMany("CrewEmployees") .HasForeignKey("CrewId") .OnDelete(DeleteBehavior.Restrict); }); - Many‐to‐One
modelBuilder.Entity("Job") .HasOne("FieldOffice") .WithMany("Jobs") .HasForeignKey("FieldOfficeId"); - Table‐Per‐Hierarchy (TPH)
modelBuilder.Entity("IrbyImaging.DomainClasses.Asset") .HasDiscriminator() .HasValue("Asset"); modelBuilder.Entity("Computer").HasDiscriminator().HasValue("Computer");
Navigation properties are also declared so that EF Core can load related data:
modelBuilder.Entity("Asset")
.Navigation("FieldOffice");
⚙️ How EF Uses This File
- Snapshot: Records the “shape” of your model at this migration.
- Diffing: When you add the next migration, EF compares your current code‐first model against this snapshot to compute
Up()/Down()changes. - Design‐Time: Visual Studio’s EF designer and CLI tooling reads this file to scaffold operations.
❌ Do not hand‐edit this file. Instead, change your domain classes and run
dotnet ef migrations add ….
👨💻 Usage Examples
1. Adding a Migration
cd IrbyImaging.DbContext
dotnet ef migrations add AddDeletedColumnJobClass
2. Inspecting the Snapshot
Search for your new column or change:
// In .Designer.cs, verify the new boolean:
modelBuilder.Entity("IrbyImaging.DomainClasses.JobClassification", b => {
b.Property<bool>("IsDeleted") // ← newly added
.HasColumnType("bit");
});
3. Applying to Database
dotnet ef database update
🛠️ Common Migration Commands
| Task | Command |
|---|---|
| Add new migration | dotnet ef migrations add <Name> |
| Apply migrations to database | dotnet ef database update |
| List pending migrations | dotnet ef migrations list |
| Remove last migration (designer & code) | dotnet ef migrations remove |
| Scaffold SQL script | dotnet ef migrations script [from] [to] |
📊 UML Diagram
classDiagram
class IrbyContext
class AddDeletedColumnJobClass {
<<Migration>>
+BuildTargetModel(modelBuilder)
}
AddDeletedColumnJobClass ..|> Microsoft.EntityFrameworkCore.Migrations.Migration
AddDeletedColumnJobClass ..> IrbyContext : [DbContext]
AddDeletedColumnJobClass --> ModelBuilder
Diagram Legend:
<<Migration>>– marks the EF migration class.- Solid arrow (
-->) – method parameters or usage.- Dotted arrow (
..>) – metadata relationships (attributes).
📝 Conclusion
This designer file is the model snapshot for your AddDeletedColumnJobClass migration. It must remain in sync with your code‐first domain model. Whenever you:
- Change your entity classes (e.g., add
IsDeletedto JobClassification), - Run
dotnet ef migrations add …,
the tooling regenerates this file to reflect the new schema shape. EF Core uses it internally to diff against future code changes and keep your database schema consistent.
Happy migrating! 🚀