Lite DB is a lightweight embedded database, suitable for low-traffic single-instance websites.

Important: Lite DB is an open-source project, and is not commercially supported. It is therefore not suitable for business-critical websites, and Redakt does not take any liability for loss of data or other issues when using Lite DB. Use at your own risk!

Installation

Install the Lite DB package with the NuGet package manager or the Package Manager Console.

PM> Install-Package Redakt.Providers.LiteDb

Service registration

Register Lite DB services in the ConfigureServices() method of your project's Startup.cs file by adding an AddLiteDbDataStore() call to the Redakt builder instance. The order in which services are added to the Redakt builder is not important.

public void ConfigureServices(IServiceCollection services)
{
    // ... framework and other services here

    var builder = services.AddRedakt();
    builder.AddLiteDbDataStore();  // Optionally pass Action<LiteDbStoreOptions> parameter.
    // ... other Redakt services
}

Configuration settings

The Lite DB database module is configured through the appsettings.json file. Any configuration that is not included in the appsettings.json file will be set to its default values.

{
    "Redakt": {
        "DataStore": {
            "LiteDB": {
                "FilePath": "App_Data\\redakt.db"
            }
        }
    }
}

Additionally, an Action<LiteDbStoreOptions> configuration delegate may be passed to the AddLiteDbDataStore() call. Configuration set through this delegate takers priority and overrides values in the appsettings.json file.

File Path

Sets the path to the Lite DB database file. It can be a relative path from the website root, or it can be a fully qualified path name. The file may be accessed on a network drive or SAN as well. Defaults to "App_Data\redakt.db" if not specified.

Redakt will create and initialize the database file upon the first installation. It is therefore not necessary to create a database in advance.