public async Task <TEntity> GetByIdAsync <TEntity>(long id) where TEntity : class { var entity = await _ctx.FindAsync <TEntity>(id); if (entity == null) { throw new EntityNotFoundException($"{typeof(TEntity).ToString().Split('.').Last()} with id {id} not found."); } return(entity); }