public async Task <bool> ExistsAsync(int id) { var dbSet = _context.Set <TEntity>(); var item = await dbSet.FindAsync(id); if (item == null) { return(false); } else { _context.Entry(item).State = EntityState.Detached; return(true); } }