원클릭으로
ef-core-configuration
Use this skill when configuring Entity Framework Core entities using the Fluent API.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use this skill when configuring Entity Framework Core entities using the Fluent API.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Design system patterns for reusable UI via atomic design, Tailwind tokens/variants, and accessibility. Use when creating atoms/molecules, theming, or hardening a11y.
Entity Framework Core best practices for configuration, queries, concurrency, and multi-tenancy.
Frontend architecture patterns for React apps (React Router 7, TanStack Query). Use when planning features, defining routes, data strategies, and component gaps.
Infrastructure standards for Docker, scripts, middleware, and authentication in multi-tenant deployments.
Integration testing performance optimization, test parallelization, cleanup strategies, and CI/CD categorization patterns. Use when optimizing test execution speed, managing test data, or structuring tests for automated pipelines.
ASP.NET Core Minimal APIs patterns for endpoints, DTOs, validation, and service integration. Use when implementing API endpoints, defining request/response contracts, or structuring API projects with clean separation of concerns.
| name | ef-core-configuration |
| description | Use this skill when configuring Entity Framework Core entities using the Fluent API. |
For each entity, create a corresponding configuration class following these exact patterns.
using GloboTicket.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace GloboTicket.Infrastructure.Data.Configurations;
/// <summary>
/// Entity Framework Core configuration for the {EntityName} entity.
/// Defines table structure, constraints, indexes, and relationships.
/// </summary>
public class {EntityName}Configuration : IEntityTypeConfiguration<{EntityName}>
{
/// <summary>
/// Configures the {EntityName} entity.
/// </summary>
/// <param name="builder">The entity type builder.</param>
public void Configure(EntityTypeBuilder<{EntityName}> builder)
{
// Configuration in exact order...
}
}
Follow this EXACT order:
builder.ToTable("Shows"); // Plural, PascalCase
builder.HasKey(s => s.Id);
builder.Property(s => s.Id).ValueGeneratedOnAdd();
builder.HasAlternateKey(e => new { e.TenantId, e.EntityGuid });
builder.HasIndex(e => e.EntityGuid); // For MultiTenantEntity
builder.Property(s => s.StartTime).IsRequired();
builder.Property(s => s.Name).IsRequired().HasMaxLength(100);
builder.HasOne(s => s.Venue)
.WithMany(v => v.Shows) // Always specify the collection on the parent
.HasForeignKey(s => s.VenueId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
builder.Property(s => s.CreatedAt).IsRequired();
builder.Property(s => s.UpdatedAt).IsRequired(false);
For entities inheriting from Entity (like Show):
public class ShowConfiguration : IEntityTypeConfiguration<Show>
{
public void Configure(EntityTypeBuilder<Show> builder)
{
// 1. Table name
builder.ToTable("Shows");
// 2. Primary key
builder.HasKey(s => s.Id);
builder.Property(s => s.Id).ValueGeneratedOnAdd();
// 3. Property configurations
builder.Property(s => s.StartTime).IsRequired();
// 4. Foreign key relationships
builder.HasOne(s => s.Venue)
.WithMany(v => v.Shows) // Collection on Venue
.HasForeignKey(s => s.VenueId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
builder.HasOne(s => s.Act)
.WithMany(a => a.Shows) // Collection on Act
.HasForeignKey(s => s.ActId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
// 5. Inherited property configurations
builder.Property(s => s.CreatedAt).IsRequired();
builder.Property(s => s.UpdatedAt).IsRequired(false);
}
}
For entities inheriting from MultiTenantEntity:
public class ActConfiguration : IEntityTypeConfiguration<Act>
{
public void Configure(EntityTypeBuilder<Act> builder)
{
// 1. Table name
builder.ToTable("Acts");
// 2. Primary key
builder.HasKey(a => a.Id);
builder.Property(a => a.Id).ValueGeneratedOnAdd();
// 3. Composite alternate key for multi-tenant uniqueness
builder.HasAlternateKey(a => new { a.TenantId, a.ActGuid });
// 4. Index on ActGuid for queries
builder.HasIndex(a => a.ActGuid);
// 5. Property configurations
builder.Property(a => a.ActGuid).IsRequired();
builder.Property(a => a.Name).IsRequired().HasMaxLength(100);
// 6. Foreign key relationship to Tenant with cascade delete
builder.HasOne(a => a.Tenant)
.WithMany()
.HasForeignKey(a => a.TenantId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
// 7. Inherited property configurations
builder.Property(a => a.CreatedAt).IsRequired();
builder.Property(a => a.UpdatedAt).IsRequired(false);
}
}
CRITICAL: When creating a child entity with a relationship to a parent entity, you MUST:
Add the collection navigation property to the parent entity
Show that belongs to Venue, add public ICollection<Show> Shows { get; set; } = new List<Show>(); to Venue/// <summary>The collection of Shows held at this venue.</summary>Configure the relationship on the many (child) side using HasOne().WithMany(parent => parent.Collection).HasForeignKey()
ShowConfiguration:builder.HasOne(s => s.Venue)
.WithMany(v => v.Shows) // Reference the collection property you added
.HasForeignKey(s => s.VenueId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
Never use empty WithMany() - This creates a "shadow" relationship without proper navigation, making the model harder to use and query.
Workflow:
Venue.cs)WithMany(parent => parent.Collection)HasMaxLength() for string propertiesDeleteBehavior.Cascade for parent-child relationshipsWithMany(parent => parent.Collection) pattern in relationship configuration on the many sideWithMany() - always reference the collection property on the parent