fix(di): DbContextOptions 수명 Singleton — AddDbContextFactory 스코프 충돌 해소 #3
Reference in New Issue
Block a user
Delete Branch "fix/dbcontextfactory-options-lifetime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
문제
AddDbContextFactory<Hc900DbContext>(싱글톤)가 ScopedDbContextOptions를 소비 → Development의ValidateOnBuild에서 기동 크래시(Cannot consume scoped service ... from singleton). Production(dotnet run)에선 검증이 꺼져 잠재.수정
AddDbContext에optionsLifetime: ServiceLifetime.Singleton추가 (EF Core 권장 패턴).DbContextOptions는 불변 설정 → 싱글톤 공유해도 동작 무변경Hc900DbContext자체는 Scoped 유지 → 기존 앱 영향 없음검증
Development(ValidateOnBuild 활성) 재기동 → 이전 크래시 사라지고 HTTP 200 정상 기동. Production도 정상.
🤖 Generated with Claude Code