Persistence Providers - NeoSOFT-Technologies/workflow-plugins GitHub Wiki

Description

Workflow persistence means to save the complete state of a workflow to a durable store. An important capability of workflows is that they can be persisted (saved and reloaded at a later time).

Since workflows are typically long running processes, they will need to be persisted to storage between steps. There are several persistence providers available as separate Nuget packages like:

  • SQL Server : Elsa.Persistence.EntityFramework.SqlServer
  • MySQL : Elsa.Persistence.EntityFramework.MySql
  • MongoDB : Elsa.Persistence.MongoDb
  • PostgreSQL : YesSql.Provider.PostgreSql

SQL Server

To use SQL Server as the EF Core provider, add the Elsa.Persistence.EntityFramework.SqlServer package.

Then update your Startup class as follows:

using Elsa.Persistence.EntityFramework.SqlServer

public void ConfigureServices(IServiceCollection services)
{
    services.AddElsa(options => options.UseEntityFrameworkPersistence(ef => ef.UseSqlServer("Server=local;Database=Elsa")));
}

By default, Elsa will use the following connection string when using SQLite: "Data Source=elsa.sqlite.db;Cache=Shared;". You can override this by importing the Elsa.Persistence.EntityFramework.SqlServer namespace to make available the default UseSqlServer() extension method that accepts a connection string as shown above.

MySQL

To use SQL Server as the EF Core provider, add the Elsa.Persistence.EntityFramework.MySql package.

Then update your Startup class as follows:

using Elsa.Persistence.EntityFramework.MySql

public void ConfigureServices(IServiceCollection services)
{
    services.AddElsa(options => options.UseEntityFrameworkPersistence(ef => ef.UseMySql("Server=localhost;Port=3306;Database=elsa;User=myuser;Password=mypassword;")));
}

MongoDB

To configure Elsa with MongoDB, add the Elsa.Persistence.MongoDb package.

Then update your Startup class as follows:

using Elsa.Persistence.MongoDb

public void ConfigureServices(IServiceCollection services)
{
    services.AddElsa(options => options.UseMongoDbPersistence(options => options.ConnectionString = "mongodb://localhost:27017/Elsa"));
}

PostgreSQL

To configure Elsa with PostreSQL, add the YesSql.Provider.PostgreSql package.

Then update your Startup class as follows:

using Elsa.Persistence.YesSql

public void ConfigureServices(IServiceCollection services)
{
    services.AddElsa(options => options.UseYesSqlPersistence(config => config.UsePostgreSql("Server=127.0.0.1;Port=5432;Database=elsa;User Id=postgres;Password=password;")));
}