WorkflowForge.Extensions.Persistence 2.0.0

dotnet add package WorkflowForge.Extensions.Persistence --version 2.0.0
                    
NuGet\Install-Package WorkflowForge.Extensions.Persistence -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WorkflowForge.Extensions.Persistence" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WorkflowForge.Extensions.Persistence" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="WorkflowForge.Extensions.Persistence" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WorkflowForge.Extensions.Persistence --version 2.0.0
                    
#r "nuget: WorkflowForge.Extensions.Persistence, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WorkflowForge.Extensions.Persistence@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WorkflowForge.Extensions.Persistence&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=WorkflowForge.Extensions.Persistence&version=2.0.0
                    
Install as a Cake Tool

WorkflowForge.Extensions.Persistence

<p align="center"> <img src="https://raw.githubusercontent.com/animatlabs/workflow-forge/main/icon.png" alt="WorkflowForge" width="120" height="120"> </p>

Workflow state persistence extension for WorkflowForge with in-memory and SQLite providers for checkpointing and recovery.

NuGet

Dependencies

InMemory Provider: ZERO external dependencies - Pure WorkflowForge
SQLite Provider: Uses Microsoft.Data.Sqlite as an external dependency (runtime unification)

Installation

dotnet add package WorkflowForge.Extensions.Persistence

Requires: .NET Standard 2.0 or later

Quick Start

In-Memory (Development/Testing)

using WorkflowForge.Extensions.Persistence.InMemory;

var provider = new InMemoryPersistenceProvider();

// Save workflow state
var state = new WorkflowState
{
    ExecutionId = foundry.ExecutionId,
    WorkflowName = workflow.Name,
    Properties = foundry.Properties.ToDictionary(x => x.Key, x => x.Value),
    CompletedOperations = new List<string> { "Op1", "Op2" }
};

await provider.SaveWorkflowStateAsync(foundry.ExecutionId, state);

// Load workflow state
var loadedState = await provider.LoadWorkflowStateAsync(foundry.ExecutionId);

SQLite (Production)

using WorkflowForge.Extensions.Persistence.SQLite;

var provider = new SQLitePersistenceProvider("workflows.db");

// Same API as InMemory
await provider.SaveWorkflowStateAsync(foundry.ExecutionId, state);
var loadedState = await provider.LoadWorkflowStateAsync(foundry.ExecutionId);

Key Features

  • Two Providers: InMemory (testing) and SQLite (production)
  • Checkpoint Support: Save workflow state at any point
  • Resume Workflows: Continue from last checkpoint
  • Pluggable Architecture: IWorkflowPersistenceProvider interface
  • Thread-Safe: Concurrent workflow support
  • Transactional: SQLite provider uses transactions

Configuration

Via appsettings.json

{
  "WorkflowForge": {
    "Extensions": {
      "Persistence": {
        "Enabled": true,
        "PersistOnOperationComplete": true,
        "PersistOnWorkflowComplete": true,
        "PersistOnFailure": true,
        "MaxVersions": 10,
        "InstanceId": "my-instance-id",
        "WorkflowKey": "my-workflow-key"
      }
    }
  }
}

Via Code

using WorkflowForge.Extensions.Persistence;

var options = new PersistenceOptions
{
    Enabled = true,
    PersistOnOperationComplete = true,
    PersistOnWorkflowComplete = true,
    PersistOnFailure = true,
    MaxVersions = 10,
    InstanceId = "my-instance-id",
    WorkflowKey = "my-workflow-key"
};

foundry.UsePersistence(provider, options);

Via Dependency Injection

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WorkflowForge.Extensions.Persistence;

services.AddPersistenceConfiguration(configuration);
var options = serviceProvider.GetRequiredService<IOptions<PersistenceOptions>>().Value;

See Configuration Guide for complete options.

Workflow State Structure

public class WorkflowState
{
    public Guid ExecutionId { get; set; }
    public string WorkflowName { get; set; }
    public Dictionary<string, object> Properties { get; set; }
    public List<string> CompletedOperations { get; set; }
    public int NextOperationIndex { get; set; }
    public DateTimeOffset CreatedAt { get; set; }
    public DateTimeOffset? UpdatedAt { get; set; }
}

Custom Persistence Provider

public class CosmosDbPersistenceProvider : IWorkflowPersistenceProvider
{
    private readonly CosmosClient _client;
    private readonly Container _container;
    
    public async Task SaveWorkflowStateAsync(
        Guid executionId,
        WorkflowState state,
        CancellationToken cancellationToken = default)
    {
        await _container.UpsertItemAsync(state, new PartitionKey(executionId.ToString()), cancellationToken: cancellationToken);
    }
    
    public async Task<WorkflowState?> LoadWorkflowStateAsync(
        Guid executionId,
        CancellationToken cancellationToken = default)
    {
        try
        {
            var response = await _container.ReadItemAsync<WorkflowState>(
                executionId.ToString(),
                new PartitionKey(executionId.ToString()),
                cancellationToken: cancellationToken);
            return response.Resource;
        }
        catch (CosmosException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
        {
            return null;
        }
    }
}

Usage Patterns

Save Checkpoint at Each Operation

foundry.OperationCompleted += async (s, e) =>
{
    var state = CreateStateFromFoundry(foundry);
    await provider.SaveWorkflowStateAsync(foundry.ExecutionId, state);
};

Resume from Checkpoint

var state = await provider.LoadWorkflowStateAsync(executionId);
if (state != null)
{
    // Restore foundry state
    foreach (var prop in state.Properties)
    {
        foundry.SetProperty(prop.Key, prop.Value);
    }
    
    // Skip completed operations
    foundry.SetProperty("NextOperationIndex", state.NextOperationIndex);
}

Documentation


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on WorkflowForge.Extensions.Persistence:

Package Downloads
WorkflowForge.Extensions.Persistence.Recovery

Recovery orchestration for WorkflowForge persistence: resume workflows from last checkpoints, with configurable retry and hooks.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 127 1/26/2026
1.0.0 209 8/9/2025

Major release v2.0.0:
- Dependency isolation: Microsoft/System assemblies resolved by runtime
- ISystemTimeProvider integrated for testability
- Enhanced documentation and samples
- Enterprise-ready for production workflows