public void RemoveAll() { foreach (var item in _context.Players) { _context.Players.Remove(item); } _context.SaveChanges(); }
public void RemoveAll() { var matches = _context.Matches .Include(m => m.MatchesPlayed) .ThenInclude(mp => mp.Player1) .Include(m => m.MatchesPlayed) .ThenInclude(mp => mp.Player2) .Include(m => m.MatchesPlayed) .ThenInclude(mp => mp.Winner); foreach (var item in matches) { item.MatchesPlayed.Clear(); _context.Matches.Remove(item); } _context.SaveChanges(); }