'Create a new hda optionally passing in it\'s history and dataset.
..note: to explicitly set hid to `None` you must pass in `hid=None`, otherwise
it will be automatically set.'

def create(self, history=None, dataset=None, flush=True, **kwargs):

    if (not dataset):
        kwargs['create_dataset'] = True
    hda = model.HistoryDatasetAssociation(history=history, dataset=dataset, sa_session=self.app.model.context, **kwargs)
    if history:
        history.add_dataset(hda, set_hid=('hid' not in kwargs))
    self.session().add(hda)
    if flush:
        self.session().flush()
    return hda
