Files
ExperionCrawler/fastTable/step2.md

2.4 KiB

STEP 2 — DbContext: DbSet + 인덱스 추가 (ExperionDbContext.cs)

사전 확인 (작업 전 반드시 수행)

  1. src/Infrastructure/Database/ExperionDbContext.cs 파일을 열어 전체 내용을 읽는다.
  2. 아래 항목을 확인하고 기록한다:
    • STEP 1이 완료되어 FastSession, FastRecord 클래스가 존재하는가? → 미완료면 STEP 1 먼저 수행
    • FastSessions DbSet이 이미 선언되어 있는가? → 있으면 작업 1 건너뜀
    • FastRecords DbSet이 이미 선언되어 있는가? → 있으면 작업 1 건너뜀
    • OnModelCreatingFastSession 인덱스 설정이 이미 있는가? → 있으면 작업 2 건너뜀
    • 기존 DbSet 선언 위치(줄 번호)를 확인한다
    • OnModelCreating 메서드의 끝 위치(줄 번호)를 확인한다

작업 1 — DbSet 추가

위치: 기존 DbSet 선언 블록 마지막 줄 바로 아래

public DbSet<FastSession> FastSessions => Set<FastSession>();
public DbSet<FastRecord>  FastRecords  => Set<FastRecord>();

작업 2 — OnModelCreating 인덱스 추가

위치: OnModelCreating 메서드 내부, 기존 마지막 설정 블록 아래

modelBuilder.Entity<FastSession>(e =>
{
    e.HasKey(x => x.Id);
    e.HasIndex(x => x.Status);
    e.HasIndex(x => x.StartedAt);
});

modelBuilder.Entity<FastRecord>(e =>
{
    e.HasKey(x => x.Id);
    e.HasIndex(x => x.SessionId);
    e.HasIndex(x => new { x.SessionId, x.TagName, x.RecordedAt });
});

사후 확인 (작업 후 반드시 수행)

  1. ExperionDbContext.cs 파일을 다시 열어 변경 내용을 읽는다.
  2. 아래 항목을 하나씩 확인한다:
    • public DbSet<FastSession> FastSessions 선언이 존재하는가?
    • public DbSet<FastRecord> FastRecords 선언이 존재하는가?
    • modelBuilder.Entity<FastSession> 블록이 OnModelCreating 안에 있는가?
    • modelBuilder.Entity<FastRecord> 블록이 OnModelCreating 안에 있는가?
    • HasIndex(x => new { x.SessionId, x.TagName, x.RecordedAt }) 복합 인덱스가 있는가?
  3. dotnet build src/Infrastructure 실행 → 에러/경고 0개 확인
  4. 문제가 있으면 수정 후 다시 빌드 확인

완료 조건

  • dotnet build src/Web/ExperionCrawler.csproj 결과: 에러 0, 경고 0 (기존 경고 포함)
  • DbSet 2개, 인덱스 설정 2블록 모두 존재