# Framework-Agnostic Install This page shows how to install Workflow Engine in a console application, worker service, or any non-ASP\.NET Core host. For ASP\.NET Core projects, use the [Web API install](https://docs.workflowengine.io/get-started/install-workflow-engine/) instead - it provides HTTP endpoints, built-in security, and multitenancy. The example below uses a console application, but the same steps apply to any .NET host. **Prerequisites:** - .NET 10 SDK - A running database (SQL Server, PostgreSQL, MySQL, Oracle, or MongoDB) - SQLite uses a local file and does not require a running server ## Step 1: Create a new console project Start by creating a console application with the .NET SDK: ```bash dotnet new console -n WorkflowConsole --framework net10.0 cd WorkflowConsole ``` ## Step 2: Install packages and write Program.cs Choose your database provider. Each tab shows the NuGet packages to install and the corresponding `Program.cs` code. ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForSQLite ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.Migrator; using OptimaJet.Workflow.SQLite; var connectionString = "Data Source=workflow.db"; var provider = new SqliteProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .RunMigrations() .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForMSSQL ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.Migrator; using OptimaJet.Workflow.DbPersistence; var connectionString = "PUT YOUR CONNECTION STRING HERE"; var provider = new MSSQLProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .RunMigrations() .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForMySQL ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.Migrator; using OptimaJet.Workflow.MySQL; var connectionString = "PUT YOUR CONNECTION STRING HERE"; var provider = new MySQLProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .RunMigrations() .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForPostgreSQL ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.Migrator; using OptimaJet.Workflow.PostgreSQL; var connectionString = "PUT YOUR CONNECTION STRING HERE"; var provider = new PostgreSQLProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .RunMigrations() .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForOracle ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.Migrator; using OptimaJet.Workflow.Oracle; var connectionString = "PUT YOUR CONNECTION STRING HERE"; var provider = new OracleProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .RunMigrations() .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` ```bash dotnet add package WorkflowEngine.NETCore-Core dotnet add package WorkflowEngine.NETCore-ProviderForMongoDB ``` Copy and paste the following code to replace the contents of `Program.cs`: ```csharp filename="Program.cs" using System.Xml.Linq; using OptimaJet.Workflow.Core.Builder; using OptimaJet.Workflow.Core.Parser; using OptimaJet.Workflow.Core.Runtime; using OptimaJet.Workflow.MongoDB; var connectionString = "PUT YOUR CONNECTION STRING HERE"; var provider = new MongoDBProvider(connectionString); var workflowBuilder = new WorkflowBuilder( provider, new XmlWorkflowParser(), provider ).WithDefaultCache(); var runtime = new WorkflowRuntime() .WithBuilder(workflowBuilder) .WithPersistenceProvider(provider) .Start(); Console.WriteLine("Workflow Runtime started. Press any key to stop."); Console.ReadKey(); await runtime.ShutdownAsync(); Console.WriteLine("Workflow Runtime stopped."); ``` The `connectionString` value needs to point to your database. For SQLite, the default `Data Source=workflow.db` creates a local file - update the path to match your project. For other providers, replace `PUT YOUR CONNECTION STRING HERE` with your actual connection string. ## Step 4: Run and verify Build and run the project to check that the runtime starts correctly: ```bash dotnet run ``` If the runtime starts without exceptions, Workflow Engine creates all required tables in your database automatically. ## Next steps - [Create Your First Workflow](https://docs.workflowengine.io/get-started/create-your-first-workflow/): Save a scheme and create a process instance through the Web API. - [Integrate the Designer](https://docs.workflowengine.io/get-started/integrate-the-designer/): Run the Designer standalone or embed it in your application. - WorkflowRuntime: Full API reference for the WorkflowRuntime class. - Persistence Providers: Compare available database providers and their features. ## Frequently asked questions **Which NuGet packages do I need for a non-ASP\.NET Core project?** Install `WorkflowEngine.NETCore-Core` and the persistence provider package matching your database - for example, `WorkflowEngine.NETCore-ProviderForSQLite` for SQLite or `WorkflowEngine.NETCore-ProviderForMSSQL` for SQL Server. The provider transitively pulls in `WorkflowEngine.NETCore-Migrator` (schema setup). **How do I initialize WorkflowRuntime without ASP\.NET Core?** Create a persistence provider instance with your connection string, pass it to `WorkflowBuilder`, call `RunMigrations()` to create the required database tables, then call `Start()`. No DI container or web host is needed. **Does Workflow Engine create its own database tables automatically?** For SQL providers, calling `RunMigrations()` during initialization creates all required tables in the target database if they do not exist, and applies any pending schema updates. You do not need to run SQL scripts manually. For MongoDB, `RunMigrations()` is not applicable. The provider creates its collections and lock records on first start, but not its indexes: create them once with `indexes.js` from the `Providers/OptimaJet.Workflow.MongoDB/SQL` folder of the [optimajet/WorkflowEngine.NET](https://github.com/optimajet/WorkflowEngine.NET) repository. After an upgrade, run the `update_.js` script of each version you pass. **Can I use Workflow Engine without a database at runtime?** No. Workflow Engine persists process state, scheme definitions, timers, and history to a database. A persistence provider is required.