Skip to content

Further Settings

altmann edited this page Aug 18, 2016 · 2 revisions

Clearing Database Before Seed

Before seeding test data into the database all entries from all entities in the database are removed. You can disable this default behaviour globally with method DisableClearBeforeSeeding().

var config = new CherrySeedConfiguration(cfg =>
{
    cfg.DisableClearBeforeSeeding();
    ...
});

Hooks

Hooks can be used to perform additional logic on specific events, such as before or after saving an entity.

Following hooks are available:

  • BeforeSave: With method BeforeSave(Action<Dictionary<string, string>, object> beforeSaveAction) you can register an action.
  • AfterSave: With method AfterSave(Action<Dictionary<string, string>, object> afterSaveAction) you can register an action.

Here is an example to register hook BeforeSave:

var config = new CherrySeedConfiguration(cfg =>
{
    cfg.BeforeSave((objDictionary, obj) =>
    {
        // do here some logging or you can 
        // also change the field values of obj
    });
    ...
});

Clone this wiki locally