feat(product): T1 — domain entities + DTO (Product, ProductCategory, BaseEntity)#51
feat(product): T1 — domain entities + DTO (Product, ProductCategory, BaseEntity)#51devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…BaseEntity) Add domain layer for Product microservice: - BaseEntity with audit fields (Id, CreatedBy, UpdatedBy, timestamps) - Product entity (drops OrderDetails nav property from monolith) - ProductCategory entity with Products collection - ProductDto matching monolith ProductVM shape - CategoryDto for category projections - Remove .gitkeep placeholders from Entities/ and Interfaces/
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
🚩 DbContext does not register new entity DbSets
The new Product and ProductCategory entities are defined but ProductDbContext (src/Services/Product/Product.Infrastructure/Data/ProductDbContext.cs) has no DbSet<> properties for them and no entity configuration in OnModelCreating. EF Core can still discover entities via navigation properties if one is registered, but currently neither is registered. This means any attempt to query or persist these entities will fail until DbSet<Product> and DbSet<ProductCategory> are added. This is likely intentional scaffolding (the TODO comment in OnModelCreating says as much), but it's worth tracking to ensure it doesn't get forgotten.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Correct — DbSet<Product> and DbSet<ProductCategory> registration is intentionally out of scope for this domain-only PR. The existing TODO in OnModelCreating tracks this; it'll be wired up when the Infrastructure layer task lands.
| public int? ParentId { get; set; } | ||
| public Product? Parent { get; set; } | ||
|
|
||
| public int ProductCategoryId { get; set; } | ||
| public required ProductCategory ProductCategory { get; set; } | ||
|
|
||
| public ICollection<Product> Children { get; } = []; |
There was a problem hiding this comment.
🚩 Self-referencing Product relationship needs explicit EF Core configuration
The Product entity has a self-referencing parent-child relationship (ParentId/Parent/Children at lines 14-20). EF Core's conventions may handle this, but the cascade delete behavior for self-referencing relationships often requires explicit configuration to avoid cycles (e.g., .OnDelete(DeleteBehavior.Restrict)). Without this, migrations may fail on SQL Server or PostgreSQL depending on provider defaults. The ProductDbContext.OnModelCreating currently has a TODO placeholder, so this should be addressed when that configuration is implemented.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Acknowledged — the self-referencing relationship will need .OnDelete(DeleteBehavior.Restrict) (or similar) in OnModelCreating. That's Infrastructure-layer work, intentionally deferred to a later task when ProductDbContext configuration is implemented.
Summary
Adds the domain layer for the Product microservice under
src/Services/Product/Product.Domain/.Entities (
Product.Domain.Entities):BaseEntity— shared audit base withId,CreatedBy/UpdatedBy([MaxLength(40)]), andCreatedDate/UpdatedDateProduct— ported from monolith, dropsICollection<OrderDetail> OrderDetailsnav property; includes self-referentialParent/Childrenand requiredProductCategoryFKProductCategory—Name/Description/Icon+ICollection<Product> ProductscollectionDTOs (
Product.Domain.DTOs):ProductDto— matches monolith'sProductVMshape, flattens category toProductCategoryNameCategoryDto— lightweight projection (Id,Name,Description,Icon)Removes
.gitkeepplaceholders fromEntities/andInterfaces/.All builds pass:
Product.Domain.csprojandProduct.API.csproj. No forbidden references (OrderDetail,Order,Customer,ApplicationUser).Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/bc5a9156cad244339c8ad8d1601e6dc2
Requested by: @mbatchelor81