📑 Migration Documentation: AddMoreColumnsToClassAndCostCodes.Designer.cs
Auto‐generated Entity Framework Core migration snapshot for the
AddMoreColumnsToClassAndCostCodesmigration.
Table of Contents
- Overview & Purpose
- File Structure
- Dependencies & Technologies
- Key Functional Areas
- Model Snapshot:
BuildTargetModel - Entities Affected
- Relationships & Indexes
- Mermaid UML Diagram
- Applying & Rolling Back Migrations
- Usage Example
- Conclusion
1. Overview & Purpose
🔍 What is this file?
This file is the EF Core–generated snapshot for the migration named 20250115193119_AddMoreColumnsToClassAndCostCodes. Its role is to tell EF Core exactly how your database schema should look after the migration is applied.
📌 Why it exists
- Tracks the state of your
DbContextmodel at a given point in time. - Enables EF Core to compare future model changes against this snapshot and generate diffs.
- Should not be edited manually—any changes to your domain classes trigger a new snapshot on the next migration.
2. File Structure
IrbyImaging.DbContext/
Migrations/
├── 20250115193119_AddMoreColumnsToClassAndCostCodes.cs // Up/Down logic
└── 20250115193119_AddMoreColumnsToClassAndCostCodes.Designer.cs // This snapshot
Inside the .Designer.cs:
- Usings & Namespace
- [DbContext] & [Migration] Attributes
- Partial Migration Class
- Override
BuildTargetModel(ModelBuilder modelBuilder)
3. Dependencies & Technologies
| Technology | Version | Purpose |
|---|---|---|
| .NET / C# | 9.0 | Runtime & language |
| Microsoft.EntityFrameworkCore | 9.0 | ORM and migrations framework |
| SQL Server | relational | Underlying database provider |
4. Key Functional Areas
-
Migration Decoration
[DbContext(typeof(IrbyContext))] [Migration("20250115193119_AddMoreColumnsToClassAndCostCodes")] partial class AddMoreColumnsToClassAndCostCodes { … }- Links the snapshot to your
IrbyContextand assigns a unique timestamp ID.
- Links the snapshot to your
-
Schema Snapshot
- The
BuildTargetModelmethod configures all entities, properties, keys, indexes, relationships as they should exist after this migration.
- The
-
Annotations & Conventions
- Sets ProductVersion and MaxIdentifierLength.
- Calls
UseIdentityColumnsfor SQL Server–style IDENTITY support.
5. Model Snapshot: BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
// Enable IDENTITY columns for SQL Server
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// ► Definitions for every EntityType follow
modelBuilder.Entity("IrbyImaging.DomainClasses.CostCode", b => {
b.Property<Guid>("CostCodeId")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("CostCodeNumber").HasColumnType("int");
b.Property<Guid>("JobId").HasColumnType("uniqueidentifier");
b.Property<string>("Name").HasColumnType("nvarchar(max)");
b.HasKey("CostCodeId");
b.HasIndex("JobId");
b.ToTable("CostCode", "irby");
});
// … all other entities are configured similarly …
#pragma warning restore 612, 618
}
- Each call to
modelBuilder.Entity(...)defines an EntityType. - Within each, properties (
b.Property<>()), keys (b.HasKey()), indexes (b.HasIndex()), and table mappings (b.ToTable()) are declared.
6. Entities Affected
Since this migration’s name refers to Class and CostCodes, the two primary DomainClasses of interest are:
| Entity | Table (Schema) | Key Column | Main Properties |
|---|---|---|---|
| CostCode | irby.CostCode |
CostCodeId |
CostCodeNumber, JobId, Name |
| EquipmentClass | irby.EquipmentClass |
EquipmentClassId |
ClassId, Name |
CostCode Entity
| Column | Type | Notes |
|---|---|---|
| CostCodeId | uniqueidentifier | PK, generated on add |
| CostCodeNumber | int | new or existing business code |
| JobId | uniqueidentifier | FK to Job entity |
| Name | nvarchar(max) | descriptive name of cost code |
EquipmentClass Entity
| Column | Type | Notes |
|---|---|---|
| EquipmentClassId | uniqueidentifier | PK, generated on add |
| ClassId | int | integer classification code |
| Name | nvarchar(max) | human‐readable class name |
ℹ️ If your Up()/Down() migration adds columns, the
.Designer.cssnapshot will include them here automatically.
7. Relationships & Indexes
-
CostCode ⇄ Job
b.HasOne("Job").WithMany().HasForeignKey("JobId")- Enforced at DB level with index on
JobId.
-
EquipmentClass
- No direct FK relationships in this snapshot—used by
EquipmentType.
- No direct FK relationships in this snapshot—used by
// Example: CostCode → Job
b.HasOne("IrbyImaging.DomainClasses.Job", "Job")
.WithMany() // no inverse navigation
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
8. Mermaid UML Diagram
classDiagram
CostCode --> Job : JobId
EquipmentClass : +Guid EquipmentClassId
EquipmentClass : +int ClassId
EquipmentClass : +string Name
Job : +Guid JobId
Job : +string Name
- Arrows indicate foreign‐key references.
- Classes list their key properties.
9. Applying & Rolling Back Migrations
# To apply this migration (and all pending):
dotnet ef database update
# To roll back one migration:
dotnet ef database update 20250115193118_PreviousMigration
- EF Core uses the
.Designer.csto compute the target snapshot. - The accompanying
.cs(without “Designer”) contains theUp()andDown()SQL or fluent API commands.
10. Usage Example
After coding new properties in your domain classes (e.g., adding ClassId to EquipmentClass), you would:
# 1. Scaffold new migration
dotnet ef migrations add AddMoreColumnsToClassAndCostCodes
# 2. Review generated
# - Up(): AlterTable AddColumn(...)
# - .Designer.cs: full snapshot updated
# 3. Apply to database
dotnet ef database update
11. Conclusion
✅ Summary
- This
.Designer.csfile is a complete snapshot of your EF Core model after the"AddMoreColumnsToClassAndCostCodes"migration. - It ensures consistency between your C# domain classes and the underlying SQL schema.
🛑 Do Not modify by hand—rely on EF Core’s CLI or Package Manager integration to keep this in sync.
🔗 Further Reading
- EF Core Migrations: https://docs.microsoft.com/ef/core/managing-schemas/migrations/
- Model Building: https://docs.microsoft.com/ef/core/modeling/
Generated with ❤️ to help you navigate your EF Core migration snapshot!