# Seed Methods Detection & Execution

## Detect Available Seed Methods

```bash
echo ""
echo "Detecting seed methods..."

SEED_METHODS=""

# HasData() in configurations (RECOMMENDED)
if grep -rq "\.HasData(" . --include="*.cs" 2>/dev/null; then
  SEED_METHODS+=" hasdata"
  echo "  - HasData(): Found"
fi

# IDataSeeder classes
if grep -rq "IDataSeeder\|class.*Seeder" . --include="*.cs" 2>/dev/null; then
  SEED_METHODS+=" seeder-class"
  echo "  - Seeder classes: Found"
fi

# --seed CLI argument
if grep -q "\-\-seed" ./src/*/Program.cs 2>/dev/null; then
  SEED_METHODS+=" cli-argument"
  echo "  - CLI --seed: Found"
fi

# WARNING: SQL scripts detected
if [ -f "./scripts/seed.sql" ] || find src -name "seed*.sql" -not -path "*/bin/*" -not -path "*/obj/*" 2>/dev/null | grep -q .; then
  echo ""
  echo "WARNING: SQL seed scripts detected - FORBIDDEN by conventions"
  echo "Migrate to HasData() or IDataSeeder"
fi

if [ -z "$SEED_METHODS" ]; then
  echo "  No seed methods found"
fi
```

## Execute Seed - HasData

```bash
echo ""
echo "HasData is applied via migrations."
echo "Running database update to ensure all HasData is applied..."

dotnet ef database update \
  --context "$DBCONTEXT" \
  --project "$INFRA_PROJECT" \
  --startup-project "$STARTUP_PROJECT"
```

## Execute Seed - Seeder Class

```bash
echo ""
echo "Running seeder class..."

dotnet run --project "$STARTUP_PROJECT" -- --seed
EXIT_CODE=$?

if [ $EXIT_CODE -ne 0 ]; then
  echo "Seed command failed or not supported (exit code: $EXIT_CODE)"
  echo "Check if --seed argument is implemented in Program.cs"
fi
```

## Execute Seed - CLI Argument

```bash
echo ""
echo "Running application with --seed..."

dotnet run --project "$STARTUP_PROJECT" -- --seed
```

## Verify Seed Data

```bash
echo ""
echo "Verifying seed data..."

# Quick check - count records in key tables
# This is application-specific
```
