📑 20240604142454_AddBiddingImaging Migration Documentation
File Path:
IrbyImaging.DbContext/Migrations/20240604142454_AddBiddingImaging.cs
📚 Table of Contents
- Overview & Purpose
- Key Functional Areas
- Schema Changes
- Dependencies & Technologies
- Entity Updates (View Models & Data Models)
- Up & Down Methods
- Mermaid UML Diagram
- Usage Examples
- Conclusion
1. Overview & Purpose 🎯
This Entity Framework Core Migration class introduces bidding-related flags and a document type identifier to support new imaging workflows in our Irby system. By adding these columns:
- 📌 We can mark temporary documents as part of a bidding process.
- 📌 We can classify stored document images by bidding-specific types.
- 📌 We can differentiate categories used for bidding vs. accounting.
This migration is intended to be applied to the target database to keep your schema in sync with the domain model.
2. Key Functional Areas 🔑
-
TempDocumentData Enhancements
AddIsBiddingflag for incoming temporary documents. -
DocumentImage Enhancements
- Add
IsBiddingflag. - Add
BiddingDocumentType(unique GUID) to categorize bidding document images.
- Add
-
DocumentCategory Enhancements
- Add
IsBiddingflag. - Add
IsAccountingflag (to explicitly tag accounting categories).
- Add
3. Schema Changes 🏗️
| Schema | Table | Column | Type | Default Value | Purpose |
|---|---|---|---|---|---|
| irby | TempDocumentData | IsBidding | bit (bool) |
false |
Marks temp data as part of bidding flow. |
| irby | DocumentImage | IsBidding | bit (bool) |
false |
Flags stored images for bidding. |
| irby | DocumentImage | BiddingDocumentType | uniqueidentifier (GUID) |
00000000-0000-0000-0000-000000000000 |
Defines type of bidding document. |
| irby | DocumentCategory | IsBidding | bit (bool) |
false |
Tags categories used in bidding. |
| irby | DocumentCategory | IsAccounting | bit (bool) |
false |
Tags categories used in accounting. |
3.1 TempDocumentData
- Column:
IsBidding - Type:
bool(bit) - Default:
false - Use Case: Identify if the temporary document is related to a bidding process.
3.2 DocumentImage
- Columns:
IsBidding(bool)BiddingDocumentType(Guid)
- Default:
false/Guid.Empty - Use Case: Maintain metadata on stored images for filtering, processing, and classification in bidding workflows.
3.3 DocumentCategory
- Columns:
IsBidding(bool)IsAccounting(bool)
- Default:
false - Use Case: Distinguish between categories used for bidding vs. accounting in downstream modules.
4. Dependencies & Technologies 🔌
- .NET 6 / .NET Core 3.1+
- Entity Framework Core
- Namespace:
Microsoft.EntityFrameworkCore.Migrations
- Namespace:
- C# 10+
- Database: SQL Server (assumed by
uniqueidentifier,bittypes)
5. Entity Updates (View Models & Data Models) 📂
Note: This migration presumes you have models updated accordingly.
For example, in your EF Core DbContext and entity classes:
public class TempDocumentData
{
public Guid Id { get; set; }
public bool IsBidding { get; set; } // ← New property
// ... other props ...
}
public class DocumentImage
{
public Guid Id { get; set; }
public bool IsBidding { get; set; } // ← New property
public Guid BiddingDocumentType { get; set; } // ← New property
// ... other props ...
}
public class DocumentCategory
{
public Guid Id { get; set; }
public bool IsBidding { get; set; } // ← New property
public bool IsAccounting { get; set; } // ← New property
// ... other props ...
}
Make sure these properties are present in your domain classes before running dotnet ef database update.
6. Up & Down Methods 🔄
Up Method
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsBidding",
schema: "irby",
table: "TempDocumentData",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<Guid>(
name: "BiddingDocumentType",
schema: "irby",
table: "DocumentImage",
type: "uniqueidentifier",
nullable: false,
defaultValue: Guid.Empty);
migrationBuilder.AddColumn<bool>(
name: "IsBidding",
schema: "irby",
table: "DocumentImage",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsAccounting",
schema: "irby",
table: "DocumentCategory",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsBidding",
schema: "irby",
table: "DocumentCategory",
type: "bit",
nullable: false,
defaultValue: false);
}
Down Method
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsBidding",
schema: "irby",
table: "TempDocumentData");
migrationBuilder.DropColumn(
name: "BiddingDocumentType",
schema: "irby",
table: "DocumentImage");
migrationBuilder.DropColumn(
name: "IsBidding",
schema: "irby",
table: "DocumentImage");
migrationBuilder.DropColumn(
name: "IsAccounting",
schema: "irby",
table: "DocumentCategory");
migrationBuilder.DropColumn(
name: "IsBidding",
schema: "irby",
table: "DocumentCategory");
}
7. Mermaid UML Diagram 📊
classDiagram
class Migration {
<<abstract>>
+Up(MigrationBuilder)
+Down(MigrationBuilder)
}
class AddBiddingImaging {
+Up(MigrationBuilder)
+Down(MigrationBuilder)
}
AddBiddingImaging --|> Migration
class MigrationBuilder
AddBiddingImaging ..> MigrationBuilder : uses
8. Usage Examples 🚀
-
Create & Apply Migration
# Generate the migration (already done) dotnet ef migrations add AddBiddingImaging # Apply to the database dotnet ef database update -
Querying Bidding Images
var biddingImages = dbContext.DocumentImages .Where(img => img.IsBidding) .ToList(); -
Tagging a Category
var cat = dbContext.DocumentCategories.Find(myCategoryId); cat.IsBidding = true; dbContext.SaveChanges();
9. Conclusion ✅
The 20240604142454_AddBiddingImaging migration is a critical step toward supporting bidding workflows in the IrbyImaging system. By augmenting key tables with IsBidding, IsAccounting, and BiddingDocumentType, developers and database administrators can:
- Filter and process documents based on their role in bidding vs. accounting.
- Extend imaging pipelines to handle new bidding-specific metadata.
- Maintain clear separation of concerns at the DB level.
Be sure to update your domain models and re-run dotnet ef database update whenever additional migrations are added to your solution. Happy coding! 🎉
End of Documentation