Skip to content

Repository

Michael Altmann edited this page Sep 21, 2016 · 9 revisions

A repository is responsible for storing, clearing and loading test data of entities in the database. Whether Entity Framework or another O/R mapping framework is used depends on the repository. It is not mandatory to store the test data in a database, you can also store it at another place like in a file or in the memory.

Existing Repositories

The Entity Framework repository is the only one available via Nuget. For more info see Entity Framework Repository.

Custom Repositories

Implementing custom repositories is as easy as implementing custom data providers. For more info see Custom Repository.

Setting Global Repository

You can set a global repository with the method WithRepository(IRepository repository) which is used globally for all entities.

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

Setting Entity Specific Repository

It is also possible to override the global repository for a specific entity. For example, one entity needs special handling before inserting it into the database. For more info see Setting Entity Specific Repository.

Clone this wiki locally