# Backend Post-Generation Verification

**Run ALL checks before proceeding to next step.**

## Check 1: Backend Build (BLOCKING)

```bash
dotnet build {SolutionName}.sln --no-restore
```

IF build fails: Read errors, fix compilation issues, re-run until success.

## Check 2: DbSet Registration (BLOCKING)

Search for `DbSet<{EntityName}>` in `I{DbContextName}.cs` or `{DbContextName}.cs`.

IF NOT found, add:
```csharp
public DbSet<{EntityName}> {EntityName}s => Set<{EntityName}>();
```

## Check 3: DI Registration (BLOCKING)

Search for `I{EntityName}Service` in `DependencyInjection.cs`.

IF NOT found, add:
```csharp
services.AddScoped<I{EntityName}Service, {EntityName}Service>();
```

## Check 4: RequirePermission Attributes (BLOCKING)

Each HTTP action MUST have `[RequirePermission(Permissions.{Application}.{Module}.{Action})]`.

## Check 5: Entity Configuration (BLOCKING)

Verify:
- `builder.ToTable("{table_prefix}{EntityName}s")` uses correct prefix
- `builder.HasKey(e => e.Id)` present
- `builder.HasIndex` for unique fields

## Check 5b: Seeding Infrastructure (first entity only)

**If this is the FIRST entity (no existing DevDataSeeder):**

1. **`Infrastructure/Persistence/Seeding/Data/SeedConstants.cs`**
```csharp
namespace {BaseNamespace}.Infrastructure.Persistence.Seeding.Data;
public static class SeedConstants
{
    public static readonly DateTime SeedDate = new(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc);
}
```

2. **`Infrastructure/Persistence/Seeding/DevDataSeeder.cs`**
```csharp
public class DevDataSeeder : IDevDataSeeder
{
    private readonly ExtensionsDbContext _context;
    private readonly ILogger<DevDataSeeder> _logger;
    public DevDataSeeder(ExtensionsDbContext context, ILogger<DevDataSeeder> logger) { _context = context; _logger = logger; }
    public async Task SeedAsync(CancellationToken cancellationToken = default)
    {
        _logger.LogInformation("Starting development data seeding...");
        // Add Seed{Entity}sAsync calls here
        _logger.LogInformation("Development data seeding complete.");
    }
}
```

3. Register: `services.AddScoped<IDevDataSeeder, DevDataSeeder>();`

## Check 5c: SqlObjects Directory (first entity only)

**If no existing SqlObjectHelper:**

1. **`Infrastructure/Persistence/SqlObjects/SqlObjectHelper.cs`** - Helper for embedded SQL resources
2. Create `Infrastructure/Persistence/SqlObjects/Functions/` directory
3. Ensure `.csproj` has: `<EmbeddedResource Include="Persistence\SqlObjects\**\*.sql" />`

## Check 6: Convention Validation (RECOMMENDED)

```
Tool: mcp__smartstack__validate_conventions
Args: target: "backend", scope: "{entity_name}"
```

Verifies naming conventions, architecture layers, required attributes, DTO patterns.
