π Documentation: UpdateCrewEmployeeTime.Designer.cs
Path:
IrbyImaging.DbContext/Migrations/20250317161629_UpdateCrewEmployeeTime.Designer.cs
Auto-generated EF Core Migration Designer β DO NOT EDIT this file directly.
π Table of Contents
- Overview & Purpose
- Migration Class:
UpdateCrewEmployeeTime - BuildTargetModel Method
- Key Entities Affected ποΈ
- Dependencies & Technologies βοΈ
- Sample Code Snippets π§©
- Usage Examples π
- Simplified UML Diagram π
- Conclusion
1. Overview & Purpose
This Designer file is part of an Entity Framework Core migration named 20250317161629_UpdateCrewEmployeeTime. When you run dotnet ef migrations add or dotnet ef database update, EF Core uses this snapshot to know what your database model looked like at the time of this migration.
- Auto-generated by the EF Core tools.
- Provides a model snapshot of all entities and their relationships.
- BuildTargetModel recreates the schema in C# so EF can diff and apply changes.
β οΈ Never modify this file manually. Use migrations or update your domain classes instead.
2. Migration Class: UpdateCrewEmployeeTime
namespace IrbyImaging.DbContext.Migrations
{
[DbContext(typeof(IrbyContext))]
[Migration("20250317161629_UpdateCrewEmployeeTime")]
partial class UpdateCrewEmployeeTime
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
// ... auto-generated entity configurations ...
}
}
}
[DbContext(typeof(IrbyContext))]
Binds this migration to theIrbyContextEF Core context.[Migration("20250317161629_UpdateCrewEmployeeTime")]
Unique timestamped identifier used by EF Core to order and apply migrations.BuildTargetModel(ModelBuilder)
Defines the complete model snapshot at this migration state.
3. BuildTargetModel Method
The heart of the designer file is the BuildTargetModel method:
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
// Entity definitions follow, e.g.:
modelBuilder.Entity("IrbyImaging.DomainClasses.CrewEmployee", b =>
{
b.Property<Guid>("CrewId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("StartTime")
.HasColumnType("datetime2");
b.HasKey("CrewId", "EmployeeId");
b.ToTable("CrewEmployee", "irby");
});
// ... thousands of lines of other entity mappings ...
}
Highlights:
- Annotations set global metadata (
ProductVersion, SQL Server specifics). UseIdentityColumns: Configures auto-increment/identity behavior on integer keys.modelBuilder.Entity(...): Configures each Domain class:- Properties (
Property<T>) - Keys (
HasKey) - Relationships (
HasOne,WithMany,HasForeignKey) - Table & Schema (
ToTable("...", "irby"))
- Properties (
4. Key Entities Affected ποΈ
While the snapshot contains all entities, this migration focuses on crew & time tables:
| Entity | Schema.Table | Notes |
|---|---|---|
| Crew | irby.Crew |
Groups of employees on a job |
| CrewEmployee | irby.CrewEmployee |
Junction table (Crew β Employee) |
| EmployeeTimesheet | irby.EmployeeTimesheet |
Timesheet per employee per crew session |
| WorkEntry | irby.WorkEntry |
Individual work record on a timesheet |
| FieldTimesheet | irby.FieldTimesheet |
High-level timesheet covering crew crews |
| EquipmentTimesheet | irby.EquipmentTimesheet |
Equipment usage logs |
These entities include a StartTime column in CrewEmployee, likely the reason for migration:
b.Property<DateTime?>("StartTime")
.HasColumnType("datetime2");
5. Dependencies & Technologies βοΈ
- .NET 7/8/9 (C# 11+)
- Entity Framework Core 9.0.0
- SQL Server as relational provider
- IrbyImaging.DbContext β custom EF Core context
6. Sample Code Snippets π§©
6.1 Inspecting CrewEmployee Mapping
modelBuilder.Entity("IrbyImaging.DomainClasses.CrewEmployee", b =>
{
b.Property<Guid>("CrewId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmployeeId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("StartTime")
.HasColumnType("datetime2");
b.HasKey("CrewId", "EmployeeId");
b.ToTable("CrewEmployee", "irby");
});
6.2 Relationship Example (Crew β CrewEmployee)
modelBuilder.Entity("IrbyImaging.DomainClasses.CrewEmployee", b =>
{
b.HasOne("IrbyImaging.DomainClasses.Crew", "Crew")
.WithMany("CrewEmployees")
.HasForeignKey("CrewId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("IrbyImaging.DomainClasses.Employee", "Employee")
.WithMany("CrewEmployees")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
7. Usage Examples π
- Create Migration
dotnet ef migrations add UpdateCrewEmployeeTime - Apply to Database
dotnet ef database update 20250317161629_UpdateCrewEmployeeTime - Revert
dotnet ef database update 20250317161629_PreviousMigration
EF Core uses the Designer file to generate SQL DDL under the hood.
8. Simplified UML Diagram π
βββββββββββ βββββββββββββββββββββ
β Crew β1ββββββββ CrewEmployee β
βββββββββββ β (PK: CrewId, Emp)β
β² β StartTime: datetime2?
β βββββββββββββββββββββ
β β²
β β
ββββββββββββββββ βββββββββββββββββ
β Employee β1βββββββ EmployeeTimesheet β
ββββββββββββββββ βββββββββββββββββ
β²
β
ββββββββββββ
β WorkEntryβ
ββββββββββββ
- Crew β CrewEmployee β Employee
- EmployeeTimesheet and WorkEntry link on timesheet details.
9. Conclusion
This auto-generated EF Core migration designer file captures a snapshot of your entire database model at the moment you added the UpdateCrewEmployeeTime migration. Its primary role is to allow EF Core toβ:
- Understand how tables and columns are structured.
- Compute the Ξ (changes) between migrations.
- Generate the appropriate SQL scripts for up/ down.
π When you modify your domain classes (e.g., adding
StartTimeonCrewEmployee), re-rundotnet ef migrations add β¦to update both the migration and its designer.
Happy Coding! π