Fixed EF Core LINQ query translation error that caused 500 errors in Login and Refresh Token endpoints.
Problem:
- UserTenantRoleRepository was using `.Value` property accessor on value objects (UserId, TenantId) in LINQ queries
- EF Core could not translate expressions like `utr.UserId.Value == userId` to SQL
- This caused System.InvalidOperationException with message "The LINQ expression could not be translated"
- Resulted in 500 Internal Server Error for Login and Refresh Token endpoints
Solution:
- Create value object instances (UserId.Create(), TenantId.Create()) before query
- Compare value objects directly instead of accessing .Value property
- EF Core can translate value object comparison due to HasConversion configuration
- Removed .Include(utr => utr.User) since User navigation is ignored in EF config
Impact:
- Login endpoint now works correctly (200 OK)
- Refresh Token endpoint now works correctly (200 OK)
- RBAC role assignment and retrieval working properly
- Resolves BUG-003 and BUG-004 from QA test report
Test Results:
- Before fix: 57% pass rate (8/14 tests)
- After fix: ~79% pass rate (11/14 tests) - core functionality restored
- Diagnostic test: All critical endpoints (Register, Login, Refresh) passing
Files Changed:
- UserTenantRoleRepository.cs: Fixed all three query methods (GetByUserAndTenantAsync, GetByUserAsync, GetByTenantAsync)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>