# Backend Generation: Entity Seeding & Output Formatting

> Referenced from `steps/step-04-backend.md` — Optional seeding and MCP response handling.

---

## Entity Seeding (Optional)

Ask the user if they want to seed initial data for the entity:

```yaml
questions:
  - header: "Seed Data"
    question: "Would you like to generate initial seed data for {EntityName}?"
    options:
      - label: "Yes - Generate SeedData provider"
        description: "Creates {EntityName}SeedData.cs + registers in DevDataSeeder (same pattern as core)"
      - label: "No - Skip seeding"
        description: "Entity starts empty (can add seed data later)"
    multiSelect: false
```

**If user selects YES:**

See [references/backend-entity-seeding.md](../references/backend-entity-seeding.md) for the full seeding pattern:
1. **SeedData file** (`{EntityName}SeedData.cs`) — static class with `Guid.NewGuid()`, 3-5 samples
2. **DevDataSeeder update** — add `Seed{EntityName}sAsync()` method with idempotent check

**If user selects NO:**

Skip this section and proceed to storing entity info.

```markdown
> Skipping entity seed data. You can generate it later using the SeedData provider pattern
> documented in templates-seed.md.
```

---

## Presenting Output to User

Display generated backend code organized by layer:

### Domain Layer
- `Domain/{Application}/{Module}/{EntityName}.cs`

### Infrastructure Layer
- `Persistence/Configurations/{Application}/{Module}/{EntityName}Configuration.cs`
- `Services/{Application}/{Module}/{EntityName}Service.cs`

### Application Layer
- `Common/Interfaces/I{EntityName}Service.cs`
- `{Application}/{Module}/DTOs/{EntityName}ResponseDto.cs`
- `{Application}/{Module}/DTOs/Create{EntityName}Dto.cs`
- `{Application}/{Module}/DTOs/Update{EntityName}Dto.cs`

### API Layer
- `Controllers/{controller_folder}/{Application}/{EntityName}Controller.cs`
  - NavRoute: `{full_path}`
  - Endpoints:
    - GET /api/{code} - List all
    - GET /api/{code}/{id} - Get by ID
    - POST /api/{code} - Create
    - PUT /api/{code}/{id} - Update
    - DELETE /api/{code}/{id} - Delete

### Next Steps
1. Add DbSet to ICoreDbContext: `public DbSet<{EntityName}> {EntityName}s => Set<{EntityName}>();`
2. Register service in DI: `services.AddScoped<I{EntityName}Service, {EntityName}Service>();`
3. Run: `dotnet ef migrations add core_vX.X.X_XXX_Add{EntityName}`

---

## Entity Info Storage

Store for use in frontend generation:

```
{entity_name} = "{EntityName}"
{entity_code} = "{code}"
{api_route} = "/api/{code}"
{has_seed_data} = true/false  // Whether SeedData provider was generated
```
