This commit is contained in:
parent
054ef81c63
commit
d019ed588b
6 changed files with 1680 additions and 5 deletions
|
|
@ -580,8 +580,13 @@ public class ImportBackgroundService : BackgroundService
|
|||
if (existingScores.Count > 0)
|
||||
await _context.BulkDeleteAsync(existingScores);
|
||||
// Also delete the ScoreImport row itself (has unique index on RecruitImportId)
|
||||
// Use Remove+SaveChanges instead of BulkDelete since BulkDelete fails with detached entities
|
||||
var scoreImportToDelete = existingScoreImport;
|
||||
_context.ChangeTracker.Clear();
|
||||
await _context.BulkDeleteAsync(new List<ScoreImport> { existingScoreImport });
|
||||
var deleteStub = new ScoreImport { Id = scoreImportToDelete.Id };
|
||||
_context.ScoreImports.Attach(deleteStub);
|
||||
_context.ScoreImports.Remove(deleteStub);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// Clear tracker to avoid stale references after BulkDelete (which bypasses EF tracking)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue