Update DB context class names and create SQL Server provider

This commit is contained in:
Sipke Schoorstra 2022-11-20 19:00:03 +01:00
parent 8cc8d1bcbf
commit 660cfbfd05
79 changed files with 2112 additions and 159 deletions

View file

@ -116,6 +116,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.TelnyxIntegrat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Composition", "src\samples\console\Elsa.Samples.Composition\Elsa.Samples.Composition.csproj", "{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore.SqlServer", "src\modules\Elsa.Persistence.EntityFrameworkCore.SqlServer\Elsa.Persistence.EntityFrameworkCore.SqlServer.csproj", "{555A4306-3BAB-409E-8BB8-3171A5867B2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -294,6 +296,10 @@ Global
{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782}.Release|Any CPU.Build.0 = Release|Any CPU
{555A4306-3BAB-409E-8BB8-3171A5867B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{555A4306-3BAB-409E-8BB8-3171A5867B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{555A4306-3BAB-409E-8BB8-3171A5867B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{555A4306-3BAB-409E-8BB8-3171A5867B2C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
@ -346,5 +352,6 @@ Global
{F09B30F7-AF33-44D7-B835-099D1F72A37E} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{55AAF940-12DC-4793-805C-992AEF2C1E8D} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{1AA0AEFC-BD58-4284-A6C5-AD15C5C79782} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{555A4306-3BAB-409E-8BB8-3171A5867B2C} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
EndGlobalSection
EndGlobal

View file

@ -2,6 +2,9 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Expressions.Models;
/// <summary>
/// Made available to activities to access shared state and store local state.
/// </summary>
public class ExpressionExecutionContext
{
private readonly IServiceProvider _serviceProvider;
@ -10,14 +13,13 @@ public class ExpressionExecutionContext
IServiceProvider serviceProvider,
MemoryRegister memory,
ExpressionExecutionContext? parentContext = default,
IDictionary<object, object>? applicationProperties = default,
IDictionary<object, object>? transientProperties = default,
CancellationToken cancellationToken = default)
{
_serviceProvider = serviceProvider;
Memory = memory;
ApplicationProperties = applicationProperties ?? new Dictionary<object, object>();
TransientProperties = transientProperties ?? new Dictionary<object, object>();
ParentContext = parentContext;
CancellationToken = cancellationToken;
}
@ -26,7 +28,11 @@ public class ExpressionExecutionContext
/// </summary>
public MemoryRegister Memory { get; }
public IDictionary<object, object> ApplicationProperties { get; set; }
/// <summary>
/// A dictionary of transient properties.
/// </summary>
public IDictionary<object, object> TransientProperties { get; set; }
public ExpressionExecutionContext? ParentContext { get; set; }
public CancellationToken CancellationToken { get; }

View file

@ -20,7 +20,7 @@ public class ConfigureJavaScriptEngineWithActivityOutput : INotificationHandler<
public async Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
{
var engine = notification.Engine;
var workflow = notification.Context.GetWorkflow();
var workflow = notification.Context.GetWorkflowExecutionContext().Workflow;
var nodes = await _activityWalker.WalkAsync(workflow.Root, cancellationToken);
var graph = nodes.Flatten();
var register = notification.Context.Memory;

View file

@ -4,4 +4,8 @@ using Jint;
namespace Elsa.JavaScript.Notifications;
/// <summary>
/// This notification is published every time a JavaScript expression is about to be evaluated.
/// It gives subscribers a chance to configure the <see cref="Engine"/> with additional functions and variables.
/// </summary>
public record EvaluatingJavaScript(Engine Engine, ExpressionExecutionContext Context) : INotification;

View file

@ -0,0 +1,18 @@
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
public abstract class SqlServerDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
{
public TDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<TDbContext>();
var connectionString = args.Any() ? args[0] : "Data Source=local";
builder.UseElsaSqlServer(connectionString);
return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
}

View file

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>
Provides SQL Server migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore sqlserver</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,12 @@
using Elsa.Persistence.EntityFrameworkCore.Common;
using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaSqlServer(this DbContextOptionsBuilder builder, string connectionString) =>
builder.UseSqlServer(connectionString, db => db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema));
}

View file

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

View file

@ -0,0 +1,88 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
{
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
[Migration("20221120175908_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("Category")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsLatest")
.HasColumnType("bit");
b.Property<bool>("IsPublished")
.HasColumnType("bit");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_ActivityDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_ActivityDefinition_IsPublished");
b.HasIndex("Type")
.HasDatabaseName("IX_ActivityDefinition_Type");
b.HasIndex("Version")
.HasDatabaseName("IX_ActivityDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_ActivityDefinition_DefinitionId_Version");
b.ToTable("ActivityDefinitions", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,76 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "ActivityDefinitions",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
Type = table.Column<string>(type: "nvarchar(450)", nullable: false),
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Category = table.Column<string>(type: "nvarchar(max)", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
IsLatest = table.Column<bool>(type: "bit", nullable: false),
IsPublished = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ActivityDefinitions", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ActivityDefinition_DefinitionId_Version",
schema: "Elsa",
table: "ActivityDefinitions",
columns: new[] { "DefinitionId", "Version" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ActivityDefinition_IsLatest",
schema: "Elsa",
table: "ActivityDefinitions",
column: "IsLatest");
migrationBuilder.CreateIndex(
name: "IX_ActivityDefinition_IsPublished",
schema: "Elsa",
table: "ActivityDefinitions",
column: "IsPublished");
migrationBuilder.CreateIndex(
name: "IX_ActivityDefinition_Type",
schema: "Elsa",
table: "ActivityDefinitions",
column: "Type");
migrationBuilder.CreateIndex(
name: "IX_ActivityDefinition_Version",
schema: "Elsa",
table: "ActivityDefinitions",
column: "Version");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ActivityDefinitions",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,86 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.ActivityDefinitions
{
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
partial class ActivityDefinitionsElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("Category")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisplayName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsLatest")
.HasColumnType("bit");
b.Property<bool>("IsPublished")
.HasColumnType("bit");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_ActivityDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_ActivityDefinition_IsPublished");
b.HasIndex("Type")
.HasDatabaseName("IX_ActivityDefinition_Type");
b.HasIndex("Version")
.HasDatabaseName("IX_ActivityDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_ActivityDefinition_DefinitionId_Version");
b.ToTable("ActivityDefinitions", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,84 @@
// <auto-generated />
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
{
[DbContext(typeof(LabelsElsaDbContext))]
[Migration("20221120175911_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("Color")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionVersionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("LabelId")
.HasDatabaseName("WorkflowDefinitionLabel_LabelId");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionId");
b.HasIndex("WorkflowDefinitionVersionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionVersionId");
b.ToTable("WorkflowDefinitionLabels", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "Labels",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
NormalizedName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Color = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Labels", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WorkflowDefinitionLabels",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowDefinitionVersionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
LabelId = table.Column<string>(type: "nvarchar(450)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowDefinitionLabels", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_LabelId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "LabelId");
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "WorkflowDefinitionId");
migrationBuilder.CreateIndex(
name: "WorkflowDefinitionLabel_WorkflowDefinitionVersionId",
schema: "Elsa",
table: "WorkflowDefinitionLabels",
column: "WorkflowDefinitionVersionId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Labels",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowDefinitionLabels",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,82 @@
// <auto-generated />
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Labels
{
[DbContext(typeof(LabelsElsaDbContext))]
partial class LabelsElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("Color")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("NormalizedName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Labels", "Elsa");
});
modelBuilder.Entity("Elsa.Labels.Entities.WorkflowDefinitionLabel", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("LabelId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionVersionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("LabelId")
.HasDatabaseName("WorkflowDefinitionLabel_LabelId");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionId");
b.HasIndex("WorkflowDefinitionVersionId")
.HasDatabaseName("WorkflowDefinitionLabel_WorkflowDefinitionVersionId");
b.ToTable("WorkflowDefinitionLabels", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,186 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
[Migration("20221120175914_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("BinaryData")
.HasColumnType("varbinary(max)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsLatest")
.HasColumnType("bit");
b.Property<bool>("IsPublished")
.HasColumnType("bit");
b.Property<string>("MaterializerContext")
.HasColumnType("nvarchar(max)");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("StringData")
.HasColumnType("nvarchar(max)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_WorkflowDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_WorkflowDefinition_IsPublished");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowDefinition_Name");
b.HasIndex("Version")
.HasDatabaseName("IX_WorkflowDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_WorkflowDefinition_DefinitionId_Version");
b.ToTable("WorkflowDefinitions", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowInstance", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("datetimeoffset");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowInstance_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowInstance_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_DefinitionId");
b.HasIndex("FaultedAt")
.HasDatabaseName("IX_WorkflowInstance_FaultedAt");
b.HasIndex("FinishedAt")
.HasDatabaseName("IX_WorkflowInstance_FinishedAt");
b.HasIndex("LastExecutedAt")
.HasDatabaseName("IX_WorkflowInstance_LastExecutedAt");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowInstance_Name");
b.HasIndex("Status")
.HasDatabaseName("IX_WorkflowInstance_Status");
b.HasIndex("SubStatus")
.HasDatabaseName("IX_WorkflowInstance_SubStatus");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus");
b.HasIndex("SubStatus", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_SubStatus_DefinitionId");
b.HasIndex("Status", "SubStatus", "DefinitionId", "Version")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version");
b.ToTable("WorkflowInstances", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,185 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "WorkflowDefinitions",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(450)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
MaterializerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
MaterializerContext = table.Column<string>(type: "nvarchar(max)", nullable: true),
StringData = table.Column<string>(type: "nvarchar(max)", nullable: true),
BinaryData = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
IsLatest = table.Column<bool>(type: "bit", nullable: false),
IsPublished = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowDefinitions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WorkflowInstances",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionVersionId = table.Column<string>(type: "nvarchar(max)", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
Status = table.Column<string>(type: "nvarchar(450)", nullable: false),
SubStatus = table.Column<string>(type: "nvarchar(450)", nullable: false),
CorrelationId = table.Column<string>(type: "nvarchar(450)", nullable: true),
Name = table.Column<string>(type: "nvarchar(450)", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
LastExecutedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
FinishedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
CancelledAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
FaultedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowInstances", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_DefinitionId_Version",
schema: "Elsa",
table: "WorkflowDefinitions",
columns: new[] { "DefinitionId", "Version" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_IsLatest",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "IsLatest");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_IsPublished",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "IsPublished");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_Name",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_WorkflowDefinition_Version",
schema: "Elsa",
table: "WorkflowDefinitions",
column: "Version");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_CorrelationId",
schema: "Elsa",
table: "WorkflowInstances",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_CreatedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
column: "DefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_FaultedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "FaultedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_FinishedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "FinishedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_LastExecutedAt",
schema: "Elsa",
table: "WorkflowInstances",
column: "LastExecutedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Name",
schema: "Elsa",
table: "WorkflowInstances",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status",
schema: "Elsa",
table: "WorkflowInstances",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "DefinitionId" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_SubStatus",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "SubStatus" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "Status", "SubStatus", "DefinitionId", "Version" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_SubStatus",
schema: "Elsa",
table: "WorkflowInstances",
column: "SubStatus");
migrationBuilder.CreateIndex(
name: "IX_WorkflowInstance_SubStatus_DefinitionId",
schema: "Elsa",
table: "WorkflowInstances",
columns: new[] { "SubStatus", "DefinitionId" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WorkflowDefinitions",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowInstances",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,184 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Management
{
[DbContext(typeof(ManagementElsaDbContext))]
partial class ManagementElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("BinaryData")
.HasColumnType("varbinary(max)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsLatest")
.HasColumnType("bit");
b.Property<bool>("IsPublished")
.HasColumnType("bit");
b.Property<string>("MaterializerContext")
.HasColumnType("nvarchar(max)");
b.Property<string>("MaterializerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("StringData")
.HasColumnType("nvarchar(max)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IsLatest")
.HasDatabaseName("IX_WorkflowDefinition_IsLatest");
b.HasIndex("IsPublished")
.HasDatabaseName("IX_WorkflowDefinition_IsPublished");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowDefinition_Name");
b.HasIndex("Version")
.HasDatabaseName("IX_WorkflowDefinition_Version");
b.HasIndex("DefinitionId", "Version")
.IsUnique()
.HasDatabaseName("IX_WorkflowDefinition_DefinitionId_Version");
b.ToTable("WorkflowDefinitions", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowInstance", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset?>("CancelledAt")
.HasColumnType("datetimeoffset");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("DefinitionVersionId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("FaultedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("FinishedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("LastExecutedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowInstance_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowInstance_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_DefinitionId");
b.HasIndex("FaultedAt")
.HasDatabaseName("IX_WorkflowInstance_FaultedAt");
b.HasIndex("FinishedAt")
.HasDatabaseName("IX_WorkflowInstance_FinishedAt");
b.HasIndex("LastExecutedAt")
.HasDatabaseName("IX_WorkflowInstance_LastExecutedAt");
b.HasIndex("Name")
.HasDatabaseName("IX_WorkflowInstance_Name");
b.HasIndex("Status")
.HasDatabaseName("IX_WorkflowInstance_Status");
b.HasIndex("SubStatus")
.HasDatabaseName("IX_WorkflowInstance_SubStatus");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus");
b.HasIndex("SubStatus", "DefinitionId")
.HasDatabaseName("IX_WorkflowInstance_SubStatus_DefinitionId");
b.HasIndex("Status", "SubStatus", "DefinitionId", "Version")
.HasDatabaseName("IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version");
b.ToTable("WorkflowInstances", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,238 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
[Migration("20221120175917_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("DefinitionVersion")
.HasColumnType("int");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowState_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowState_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowState_DefinitionId");
b.HasIndex("UpdatedAt")
.HasDatabaseName("IX_WorkflowState_UpdatedAt");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowState_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus");
b.HasIndex("Status", "SubStatus", "DefinitionId", "DefinitionVersion")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion");
b.ToTable("WorkflowStates", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredTrigger", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("Hash")
.HasColumnType("nvarchar(450)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Hash")
.HasDatabaseName("IX_StoredTrigger_Hash");
b.HasIndex("Name")
.HasDatabaseName("IX_StoredTrigger_Name");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_StoredTrigger_WorkflowDefinitionId");
b.ToTable("WorkflowTriggers", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.WorkflowExecutionLogRecord", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("EventName")
.HasColumnType("nvarchar(450)");
b.Property<string>("Message")
.HasColumnType("nvarchar(max)");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("nvarchar(450)");
b.Property<string>("PayloadData")
.HasColumnType("nvarchar(max)");
b.Property<string>("Source")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("datetimeoffset");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("WorkflowVersion")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityId");
b.HasIndex("ActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityInstanceId");
b.HasIndex("ActivityType")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityType");
b.HasIndex("EventName")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_EventName");
b.HasIndex("ParentActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ParentActivityInstanceId");
b.HasIndex("Timestamp")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_Timestamp");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowDefinitionId");
b.HasIndex("WorkflowInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowInstanceId");
b.HasIndex("WorkflowVersion")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowVersion");
b.ToTable("WorkflowExecutionLogRecords", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Models.StoredBookmark", b =>
{
b.Property<string>("BookmarkId")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(max)");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("BookmarkId");
b.HasIndex(new[] { "ActivityTypeName" }, "IX_StoredBookmark_ActivityTypeName");
b.HasIndex(new[] { "ActivityTypeName", "Hash" }, "IX_StoredBookmark_ActivityTypeName_Hash");
b.HasIndex(new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" }, "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId");
b.HasIndex(new[] { "Hash" }, "IX_StoredBookmark_Hash");
b.HasIndex(new[] { "WorkflowInstanceId" }, "IX_StoredBookmark_WorkflowInstanceId");
b.ToTable("Bookmarks", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,256 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Elsa");
migrationBuilder.CreateTable(
name: "Bookmarks",
schema: "Elsa",
columns: table => new
{
BookmarkId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ActivityTypeName = table.Column<string>(type: "nvarchar(450)", nullable: false),
Hash = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowInstanceId = table.Column<string>(type: "nvarchar(450)", nullable: false),
CorrelationId = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Bookmarks", x => x.BookmarkId);
});
migrationBuilder.CreateTable(
name: "WorkflowExecutionLogRecords",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowInstanceId = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowVersion = table.Column<int>(type: "int", nullable: false),
ActivityInstanceId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ParentActivityInstanceId = table.Column<string>(type: "nvarchar(450)", nullable: true),
ActivityId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ActivityType = table.Column<string>(type: "nvarchar(450)", nullable: false),
Timestamp = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
EventName = table.Column<string>(type: "nvarchar(450)", nullable: true),
Message = table.Column<string>(type: "nvarchar(max)", nullable: true),
Source = table.Column<string>(type: "nvarchar(max)", nullable: true),
PayloadData = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowExecutionLogRecords", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WorkflowStates",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
DefinitionVersion = table.Column<int>(type: "int", nullable: false),
CorrelationId = table.Column<string>(type: "nvarchar(450)", nullable: true),
Status = table.Column<string>(type: "nvarchar(450)", nullable: false),
SubStatus = table.Column<string>(type: "nvarchar(450)", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
Data = table.Column<string>(type: "nvarchar(max)", nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowStates", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WorkflowTriggers",
schema: "Elsa",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
WorkflowDefinitionId = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
ActivityId = table.Column<string>(type: "nvarchar(max)", nullable: false),
Hash = table.Column<string>(type: "nvarchar(450)", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkflowTriggers", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName",
schema: "Elsa",
table: "Bookmarks",
column: "ActivityTypeName");
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName_Hash",
schema: "Elsa",
table: "Bookmarks",
columns: new[] { "ActivityTypeName", "Hash" });
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId",
schema: "Elsa",
table: "Bookmarks",
columns: new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" });
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_Hash",
schema: "Elsa",
table: "Bookmarks",
column: "Hash");
migrationBuilder.CreateIndex(
name: "IX_StoredBookmark_WorkflowInstanceId",
schema: "Elsa",
table: "Bookmarks",
column: "WorkflowInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ActivityType",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ActivityType");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_EventName",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "EventName");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_ParentActivityInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "ParentActivityInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_Timestamp",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "Timestamp");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowInstanceId",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowInstanceId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowExecutionLogRecord_WorkflowVersion",
schema: "Elsa",
table: "WorkflowExecutionLogRecords",
column: "WorkflowVersion");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_CorrelationId",
schema: "Elsa",
table: "WorkflowStates",
column: "CorrelationId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_CreatedAt",
schema: "Elsa",
table: "WorkflowStates",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_DefinitionId",
schema: "Elsa",
table: "WorkflowStates",
column: "DefinitionId");
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_DefinitionId",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "DefinitionId" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_SubStatus",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "SubStatus" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion",
schema: "Elsa",
table: "WorkflowStates",
columns: new[] { "Status", "SubStatus", "DefinitionId", "DefinitionVersion" });
migrationBuilder.CreateIndex(
name: "IX_WorkflowState_UpdatedAt",
schema: "Elsa",
table: "WorkflowStates",
column: "UpdatedAt");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_Hash",
schema: "Elsa",
table: "WorkflowTriggers",
column: "Hash");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_Name",
schema: "Elsa",
table: "WorkflowTriggers",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_StoredTrigger_WorkflowDefinitionId",
schema: "Elsa",
table: "WorkflowTriggers",
column: "WorkflowDefinitionId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Bookmarks",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowExecutionLogRecords",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowStates",
schema: "Elsa");
migrationBuilder.DropTable(
name: "WorkflowTriggers",
schema: "Elsa");
}
}
}

View file

@ -0,0 +1,236 @@
// <auto-generated />
using System;
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Migrations.Runtime
{
[DbContext(typeof(RuntimeElsaDbContext))]
partial class RuntimeElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Elsa")
.HasAnnotation("ProductVersion", "6.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("DefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("DefinitionVersion")
.HasColumnType("int");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("SubStatus")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("CorrelationId")
.HasDatabaseName("IX_WorkflowState_CorrelationId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_WorkflowState_CreatedAt");
b.HasIndex("DefinitionId")
.HasDatabaseName("IX_WorkflowState_DefinitionId");
b.HasIndex("UpdatedAt")
.HasDatabaseName("IX_WorkflowState_UpdatedAt");
b.HasIndex("Status", "DefinitionId")
.HasDatabaseName("IX_WorkflowState_Status_DefinitionId");
b.HasIndex("Status", "SubStatus")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus");
b.HasIndex("Status", "SubStatus", "DefinitionId", "DefinitionVersion")
.HasDatabaseName("IX_WorkflowState_Status_SubStatus_DefinitionId_DefinitionVersion");
b.ToTable("WorkflowStates", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.StoredTrigger", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<string>("Hash")
.HasColumnType("nvarchar(450)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Hash")
.HasDatabaseName("IX_StoredTrigger_Hash");
b.HasIndex("Name")
.HasDatabaseName("IX_StoredTrigger_Name");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_StoredTrigger_WorkflowDefinitionId");
b.ToTable("WorkflowTriggers", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Entities.WorkflowExecutionLogRecord", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityType")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("EventName")
.HasColumnType("nvarchar(450)");
b.Property<string>("Message")
.HasColumnType("nvarchar(max)");
b.Property<string>("ParentActivityInstanceId")
.HasColumnType("nvarchar(450)");
b.Property<string>("PayloadData")
.HasColumnType("nvarchar(max)");
b.Property<string>("Source")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("datetimeoffset");
b.Property<string>("WorkflowDefinitionId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("WorkflowVersion")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ActivityId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityId");
b.HasIndex("ActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityInstanceId");
b.HasIndex("ActivityType")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ActivityType");
b.HasIndex("EventName")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_EventName");
b.HasIndex("ParentActivityInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_ParentActivityInstanceId");
b.HasIndex("Timestamp")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_Timestamp");
b.HasIndex("WorkflowDefinitionId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowDefinitionId");
b.HasIndex("WorkflowInstanceId")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowInstanceId");
b.HasIndex("WorkflowVersion")
.HasDatabaseName("IX_WorkflowExecutionLogRecord_WorkflowVersion");
b.ToTable("WorkflowExecutionLogRecords", "Elsa");
});
modelBuilder.Entity("Elsa.Workflows.Runtime.Models.StoredBookmark", b =>
{
b.Property<string>("BookmarkId")
.HasColumnType("nvarchar(450)");
b.Property<string>("ActivityTypeName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(max)");
b.Property<string>("Hash")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("WorkflowInstanceId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("BookmarkId");
b.HasIndex(new[] { "ActivityTypeName" }, "IX_StoredBookmark_ActivityTypeName");
b.HasIndex(new[] { "ActivityTypeName", "Hash" }, "IX_StoredBookmark_ActivityTypeName_Hash");
b.HasIndex(new[] { "ActivityTypeName", "Hash", "WorkflowInstanceId" }, "IX_StoredBookmark_ActivityTypeName_Hash_WorkflowInstanceId");
b.HasIndex(new[] { "Hash" }, "IX_StoredBookmark_Hash");
b.HasIndex(new[] { "WorkflowInstanceId" }, "IX_StoredBookmark_WorkflowInstanceId");
b.ToTable("Bookmarks", "Elsa");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,9 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.ActivityDefinitions;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<ActivityDefinitionsElsaDbContext>
{
}

View file

@ -0,0 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.ActivityDefinitions;
public static class Extensions
{
public static EFCoreActivityDefinitionsPersistenceFeature UseSqlServer(this EFCoreActivityDefinitionsPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Labels;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<LabelsElsaDbContext>
{
}

View file

@ -0,0 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Labels;
public static class Extensions
{
public static EFCoreLabelPersistenceFeature UseSqlServer(this EFCoreLabelPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Management;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<ManagementElsaDbContext>
{
}

View file

@ -0,0 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Management;
public static class Extensions
{
public static EFCoreManagementPersistenceFeature UseSqlServer(this EFCoreManagementPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
return feature;
}
}

View file

@ -0,0 +1,9 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Runtime;
// ReSharper disable once UnusedType.Global
public class DesignTimeRuntimeDbContextFactory : SqlServerDesignTimeDbContextFactoryBase<RuntimeElsaDbContext>
{
}

View file

@ -0,0 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
using Elsa.Persistence.EntityFrameworkCore.SqlServer.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.SqlServer.Modules.Runtime;
public static class Extensions
{
public static EFCoreRuntimePersistenceFeature UseSqlServer(this EFCoreRuntimePersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
return feature;
}
}

View file

@ -0,0 +1,4 @@
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime

View file

@ -0,0 +1,4 @@
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime

View file

@ -2,18 +2,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
public abstract class SqliteDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
{
public abstract class SqliteDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
public TDbContext CreateDbContext(string[] args)
{
public TDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<TDbContext>();
var connectionString = args.Any() ? args[0] : Constants.DefaultConnectionString;
var builder = new DbContextOptionsBuilder<TDbContext>();
var connectionString = args.Any() ? args[0] : Constants.DefaultConnectionString;
builder.UseElsaSqlite(connectionString);
builder.UseElsaSqlite(connectionString);
return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
}

View file

@ -6,13 +6,13 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>
Provides a SQLite migrations for various modules.
Provides SQLite migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore sqlite</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@ -22,4 +22,8 @@
<ProjectReference Include="..\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project>

View file

@ -1,13 +1,12 @@
using Elsa.Persistence.EntityFrameworkCore.Common;
using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
public static class DbContextOptionsBuilderExtensions
{
public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaSqlite(this DbContextOptionsBuilder builder, string connectionString = Constants.DefaultConnectionString) =>
builder.UseSqlite(connectionString, db => db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(DbContextBase.MigrationsHistoryTable, DbContextBase.ElsaSchema));
}
public static DbContextOptionsBuilder UseElsaSqlite(this DbContextOptionsBuilder builder, string connectionString = Constants.DefaultConnectionString) =>
builder.UseSqlite(connectionString, db => db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema));
}

View file

@ -9,14 +9,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
{
[DbContext(typeof(ActivityDefinitionsDbContext))]
[Migration("20220906152713_Initial")]
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
[Migration("20221120175500_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b =>
{

View file

@ -8,13 +8,13 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.ActivityDefinitions
{
[DbContext(typeof(ActivityDefinitionsDbContext))]
partial class ActivityDefinitionsDbContextModelSnapshot : ModelSnapshot
[DbContext(typeof(ActivityDefinitionsElsaDbContext))]
partial class ActivityDefinitionsElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.ActivityDefinitions.Entities.ActivityDefinition", b =>
{

View file

@ -9,14 +9,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Labels
{
[DbContext(typeof(LabelsDbContext))]
[Migration("20220906152718_Initial")]
[DbContext(typeof(LabelsElsaDbContext))]
[Migration("20221120175503_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{

View file

@ -8,13 +8,13 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Labels
{
[DbContext(typeof(LabelsDbContext))]
partial class LabelsDbContextModelSnapshot : ModelSnapshot
[DbContext(typeof(LabelsElsaDbContext))]
partial class LabelsElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Labels.Entities.Label", b =>
{

View file

@ -10,14 +10,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Management
{
[DbContext(typeof(ManagementDbContext))]
[Migration("20220906152722_Initial")]
[DbContext(typeof(ManagementElsaDbContext))]
[Migration("20221120175506_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{

View file

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable

View file

@ -9,13 +9,13 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Management
{
[DbContext(typeof(ManagementDbContext))]
partial class ManagementDbContextModelSnapshot : ModelSnapshot
[DbContext(typeof(ManagementElsaDbContext))]
partial class ManagementElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Workflows.Management.Entities.WorkflowDefinition", b =>
{

View file

@ -10,14 +10,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Runtime
{
[DbContext(typeof(RuntimeDbContext))]
[Migration("20221117150532_Initial")]
[DbContext(typeof(RuntimeElsaDbContext))]
[Migration("20221120175509_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{

View file

@ -9,13 +9,13 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Migrations.Runtime
{
[DbContext(typeof(RuntimeDbContext))]
partial class RuntimeDbContextModelSnapshot : ModelSnapshot
[DbContext(typeof(RuntimeElsaDbContext))]
partial class RuntimeElsaDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.8");
modelBuilder.HasAnnotation("ProductVersion", "6.0.11");
modelBuilder.Entity("Elsa.Workflows.Core.State.WorkflowState", b =>
{

View file

@ -4,6 +4,6 @@ using Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ActivityDefinitionsDbContext>
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ActivityDefinitionsElsaDbContext>
{
}

View file

@ -1,14 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions;
public static class Extensions
{
public static class Extensions
public static EFCoreActivityDefinitionsPersistenceFeature UseSqlite(this EFCoreActivityDefinitionsPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
public static EFCoreActivityDefinitionsPersistenceFeature UseSqlite(this EFCoreActivityDefinitionsPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
}

View file

@ -4,6 +4,6 @@ using Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<LabelsDbContext>
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<LabelsElsaDbContext>
{
}

View file

@ -1,14 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels;
public static class Extensions
{
public static class Extensions
public static EFCoreLabelPersistenceFeature UseSqlite(this EFCoreLabelPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
public static EFCoreLabelPersistenceFeature UseSqlite(this EFCoreLabelPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
}

View file

@ -4,6 +4,6 @@ using Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Management;
// ReSharper disable once UnusedType.Global
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ManagementDbContext>
public class DesignTimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<ManagementElsaDbContext>
{
}

View file

@ -1,14 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Management;
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Management
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Management;
public static class Extensions
{
public static class Extensions
public static EFCoreManagementPersistenceFeature UseSqlite(this EFCoreManagementPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
public static EFCoreManagementPersistenceFeature UseSqlite(this EFCoreManagementPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
}

View file

@ -4,6 +4,6 @@ using Elsa.Persistence.EntityFrameworkCore.Sqlite.Abstractions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime;
// ReSharper disable once UnusedType.Global
public class SqliteDesignTimeRuntimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<RuntimeDbContext>
public class SqliteDesignTimeRuntimeDbContextFactory : SqliteDesignTimeDbContextFactoryBase<RuntimeElsaDbContext>
{
}

View file

@ -1,14 +1,13 @@
using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
using Elsa.Persistence.EntityFrameworkCore.Sqlite.Extensions;
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime
namespace Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime;
public static class Extensions
{
public static class Extensions
public static EFCoreRuntimePersistenceFeature UseSqlite(this EFCoreRuntimePersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
public static EFCoreRuntimePersistenceFeature UseSqlite(this EFCoreRuntimePersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
}
}

View file

@ -1,4 +1,4 @@
dotnet ef migrations add Initial -c ActivityDefinitionsDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeDbContext -o Migrations/Runtime
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime

View file

@ -1,4 +1,4 @@
dotnet ef migrations add Initial -c ActivityDefinitionsDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeDbContext -o Migrations/Runtime
dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions
dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels
dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management
dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime

View file

@ -7,17 +7,18 @@ namespace Elsa.Persistence.EntityFrameworkCore.Common;
/// <summary>
/// An optional base class to implement with some opinions on certain converters to install for certain DB providers.
/// </summary>
public abstract class DbContextBase : DbContext
public abstract class ElsaDbContextBase : DbContext
{
public const string ElsaSchema = "Elsa";
public const string MigrationsHistoryTable = "__EFMigrationsHistory";
protected DbContextBase(DbContextOptions options) : base(options)
protected ElsaDbContextBase(DbContextOptions options) : base(options)
{
}
protected virtual string Schema => ElsaSchema;
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (!string.IsNullOrWhiteSpace(Schema))

View file

@ -14,10 +14,10 @@
<ItemGroup>
<PackageReference Include="EFCore.BulkExtensions" Version="6.4.2" />
<PackageReference Include="LinqKit" Version="1.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -14,10 +14,10 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
public class EFCoreActivityDefinitionStore : IActivityDefinitionStore
{
private readonly Store<ActivityDefinitionsDbContext, ActivityDefinition> _store;
private readonly Store<ActivityDefinitionsElsaDbContext, ActivityDefinition> _store;
private readonly SerializerOptionsProvider _serializerOptionsProvider;
public EFCoreActivityDefinitionStore(Store<ActivityDefinitionsDbContext, ActivityDefinition> store, SerializerOptionsProvider serializerOptionsProvider)
public EFCoreActivityDefinitionStore(Store<ActivityDefinitionsElsaDbContext, ActivityDefinition> store, SerializerOptionsProvider serializerOptionsProvider)
{
_store = store;
_serializerOptionsProvider = serializerOptionsProvider;
@ -77,7 +77,7 @@ public class EFCoreActivityDefinitionStore : IActivityDefinitionStore
return await _store.DeleteWhereAsync(x => definitionIdList.Contains(x.DefinitionId), cancellationToken);
}
public ActivityDefinition Save(ActivityDefinitionsDbContext dbContext, ActivityDefinition entity)
public ActivityDefinition Save(ActivityDefinitionsElsaDbContext activityDefinitionsElsaDbContext, ActivityDefinition entity)
{
var data = new
{
@ -89,17 +89,17 @@ public class EFCoreActivityDefinitionStore : IActivityDefinitionStore
var options = _serializerOptionsProvider.CreatePersistenceOptions();
var json = JsonSerializer.Serialize(data, options);
dbContext.Entry(entity).Property("Data").CurrentValue = json;
activityDefinitionsElsaDbContext.Entry(entity).Property("Data").CurrentValue = json;
return entity;
}
public ActivityDefinition? Load(ActivityDefinitionsDbContext dbContext, ActivityDefinition? entity)
public ActivityDefinition? Load(ActivityDefinitionsElsaDbContext activityDefinitionsElsaDbContext, ActivityDefinition? entity)
{
if (entity == null)
return null;
var data = new ActivityDefinitionState(entity.Variables, entity.Metadata, entity.ApplicationProperties);
var json = (string?)dbContext.Entry(entity).Property("Data").CurrentValue;
var json = (string?)activityDefinitionsElsaDbContext.Entry(entity).Property("Data").CurrentValue;
if (!string.IsNullOrWhiteSpace(json))
{

View file

@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
public class ActivityDefinitionsDbContext : DbContextBase
public class ActivityDefinitionsElsaDbContext : ElsaDbContextBase
{
public ActivityDefinitionsDbContext(DbContextOptions options) : base(options)
public ActivityDefinitionsElsaDbContext(DbContextOptions options) : base(options)
{
}

View file

@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions;
[DependsOn(typeof(ActivityDefinitionsFeature))]
public class EFCoreActivityDefinitionsPersistenceFeature : PersistenceFeatureBase<ActivityDefinitionsDbContext>
public class EFCoreActivityDefinitionsPersistenceFeature : PersistenceFeatureBase<ActivityDefinitionsElsaDbContext>
{
public EFCoreActivityDefinitionsPersistenceFeature(IModule module) : base(module)
{

View file

@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
public class LabelsDbContext : DbContextBase
public class LabelsElsaDbContext : ElsaDbContextBase
{
public LabelsDbContext(DbContextOptions options) : base(options)
public LabelsElsaDbContext(DbContextOptions options) : base(options)
{
}

View file

@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
[DependsOn(typeof(LabelsFeature))]
public class EFCoreLabelPersistenceFeature : PersistenceFeatureBase<LabelsDbContext>
public class EFCoreLabelPersistenceFeature : PersistenceFeatureBase<LabelsElsaDbContext>
{
public EFCoreLabelPersistenceFeature(IModule module) : base(module)
{

View file

@ -8,10 +8,10 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
public class EFCoreLabelStore : ILabelStore
{
private readonly Store<LabelsDbContext, Label> _labelStore;
private readonly Store<LabelsDbContext, WorkflowDefinitionLabel> _workflowDefinitionLabelStore;
private readonly Store<LabelsElsaDbContext, Label> _labelStore;
private readonly Store<LabelsElsaDbContext, WorkflowDefinitionLabel> _workflowDefinitionLabelStore;
public EFCoreLabelStore(Store<LabelsDbContext, Label> labelStore, Store<LabelsDbContext, WorkflowDefinitionLabel> workflowDefinitionLabelStore)
public EFCoreLabelStore(Store<LabelsElsaDbContext, Label> labelStore, Store<LabelsElsaDbContext, WorkflowDefinitionLabel> workflowDefinitionLabelStore)
{
_labelStore = labelStore;
_workflowDefinitionLabelStore = workflowDefinitionLabelStore;

View file

@ -6,8 +6,8 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Labels;
public class EFCoreWorkflowDefinitionLabelStore : IWorkflowDefinitionLabelStore
{
private readonly Store<LabelsDbContext, WorkflowDefinitionLabel> _store;
public EFCoreWorkflowDefinitionLabelStore(Store<LabelsDbContext, WorkflowDefinitionLabel> store) => _store = store;
private readonly Store<LabelsElsaDbContext, WorkflowDefinitionLabel> _store;
public EFCoreWorkflowDefinitionLabelStore(Store<LabelsElsaDbContext, WorkflowDefinitionLabel> store) => _store = store;
public async Task SaveAsync(WorkflowDefinitionLabel record, CancellationToken cancellationToken = default) => await _store.SaveAsync(record, cancellationToken);
public async Task SaveManyAsync(IEnumerable<WorkflowDefinitionLabel> records, CancellationToken cancellationToken = default) => await _store.SaveManyAsync(records, cancellationToken);

View file

@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
public class ManagementDbContext : DbContextBase
public class ManagementElsaDbContext : ElsaDbContextBase
{
public ManagementDbContext(DbContextOptions options) : base(options)
public ManagementElsaDbContext(DbContextOptions options) : base(options)
{
}

View file

@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
[DependsOn(typeof(WorkflowManagementFeature))]
public class EFCoreManagementPersistenceFeature : PersistenceFeatureBase<ManagementDbContext>
public class EFCoreManagementPersistenceFeature : PersistenceFeatureBase<ManagementElsaDbContext>
{
public EFCoreManagementPersistenceFeature(IModule module) : base(module)
{

View file

@ -14,10 +14,10 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
{
private readonly Store<ManagementDbContext, WorkflowDefinition> _store;
private readonly Store<ManagementElsaDbContext, WorkflowDefinition> _store;
private readonly SerializerOptionsProvider _serializerOptionsProvider;
public EFCoreWorkflowDefinitionStore(Store<ManagementDbContext, WorkflowDefinition> store, SerializerOptionsProvider serializerOptionsProvider)
public EFCoreWorkflowDefinitionStore(Store<ManagementElsaDbContext, WorkflowDefinition> store, SerializerOptionsProvider serializerOptionsProvider)
{
_store = store;
_serializerOptionsProvider = serializerOptionsProvider;
@ -122,7 +122,7 @@ public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
return await _store.AnyAsync(predicate, cancellationToken);
}
private WorkflowDefinition Save(ManagementDbContext dbContext, WorkflowDefinition entity)
private WorkflowDefinition Save(ManagementElsaDbContext managementElsaDbContext, WorkflowDefinition entity)
{
var data = new
{
@ -134,17 +134,17 @@ public class EFCoreWorkflowDefinitionStore : IWorkflowDefinitionStore
var options = _serializerOptionsProvider.CreatePersistenceOptions();
var json = JsonSerializer.Serialize(data, options);
dbContext.Entry(entity).Property("Data").CurrentValue = json;
managementElsaDbContext.Entry(entity).Property("Data").CurrentValue = json;
return entity;
}
private WorkflowDefinition? Load(ManagementDbContext dbContext, WorkflowDefinition? entity)
private WorkflowDefinition? Load(ManagementElsaDbContext managementElsaDbContext, WorkflowDefinition? entity)
{
if (entity == null)
return null;
var data = new WorkflowDefinitionState(entity.Variables, entity.Metadata, entity.ApplicationProperties);
var json = (string?)dbContext.Entry(entity).Property("Data").CurrentValue;
var json = (string?)managementElsaDbContext.Entry(entity).Property("Data").CurrentValue;
if (!string.IsNullOrWhiteSpace(json))
{

View file

@ -17,13 +17,13 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Management;
/// </summary>
public class EFCoreWorkflowInstanceStore : IWorkflowInstanceStore
{
private readonly Store<ManagementDbContext, WorkflowInstance> _store;
private readonly Store<ManagementElsaDbContext, WorkflowInstance> _store;
private readonly SerializerOptionsProvider _serializerOptionsProvider;
/// <summary>
/// Constructor.
/// </summary>
public EFCoreWorkflowInstanceStore(Store<ManagementDbContext, WorkflowInstance> store, SerializerOptionsProvider serializerOptionsProvider)
public EFCoreWorkflowInstanceStore(Store<ManagementElsaDbContext, WorkflowInstance> store, SerializerOptionsProvider serializerOptionsProvider)
{
_store = store;
_serializerOptionsProvider = serializerOptionsProvider;
@ -94,23 +94,23 @@ public class EFCoreWorkflowInstanceStore : IWorkflowInstanceStore
return await query.PaginateAsync(x => WorkflowInstanceSummary.FromInstance(x), pageArgs);
}
public WorkflowInstance Save(ManagementDbContext dbContext, WorkflowInstance entity)
public WorkflowInstance Save(ManagementElsaDbContext managementElsaDbContext, WorkflowInstance entity)
{
var data = new WorkflowInstanceState(entity.WorkflowState, entity.Fault);
var options = _serializerOptionsProvider.CreatePersistenceOptions(ReferenceHandler.Preserve);
var json = JsonSerializer.Serialize(data, options);
dbContext.Entry(entity).Property("Data").CurrentValue = json;
managementElsaDbContext.Entry(entity).Property("Data").CurrentValue = json;
return entity;
}
public WorkflowInstance? Load(ManagementDbContext dbContext, WorkflowInstance? entity)
public WorkflowInstance? Load(ManagementElsaDbContext managementElsaDbContext, WorkflowInstance? entity)
{
if (entity == null)
return null;
var data = new WorkflowInstanceState(entity.WorkflowState, entity.Fault);
var json = (string?)dbContext.Entry(entity).Property("Data").CurrentValue;
var json = (string?)managementElsaDbContext.Entry(entity).Property("Data").CurrentValue;
if (!string.IsNullOrWhiteSpace(json))
{

View file

@ -6,8 +6,8 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
public class EFCoreBookmarkStore : IBookmarkStore
{
private readonly Store<RuntimeDbContext, StoredBookmark> _store;
public EFCoreBookmarkStore(Store<RuntimeDbContext, StoredBookmark> store) => _store = store;
private readonly Store<RuntimeElsaDbContext, StoredBookmark> _store;
public EFCoreBookmarkStore(Store<RuntimeElsaDbContext, StoredBookmark> store) => _store = store;
public async ValueTask SaveAsync(
string activityTypeName,

View file

@ -7,9 +7,9 @@ using Microsoft.EntityFrameworkCore;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
public class RuntimeDbContext : DbContextBase
public class RuntimeElsaDbContext : ElsaDbContextBase
{
public RuntimeDbContext(DbContextOptions options) : base(options)
public RuntimeElsaDbContext(DbContextOptions options) : base(options)
{
}

View file

@ -10,7 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
[DependsOn(typeof(WorkflowRuntimeFeature))]
public class EFCoreRuntimePersistenceFeature : PersistenceFeatureBase<RuntimeDbContext>
public class EFCoreRuntimePersistenceFeature : PersistenceFeatureBase<RuntimeElsaDbContext>
{
public EFCoreRuntimePersistenceFeature(IModule module) : base(module)
{

View file

@ -6,9 +6,9 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
public class EFCoreTriggerStore : ITriggerStore
{
private readonly Store<RuntimeDbContext, StoredTrigger> _store;
private readonly Store<RuntimeElsaDbContext, StoredTrigger> _store;
public EFCoreTriggerStore(Store<RuntimeDbContext, StoredTrigger> store)
public EFCoreTriggerStore(Store<RuntimeElsaDbContext, StoredTrigger> store)
{
_store = store;
}

View file

@ -8,8 +8,8 @@ namespace Elsa.Persistence.EntityFrameworkCore.Modules.Runtime;
public class EFCoreWorkflowExecutionLogStore : IWorkflowExecutionLogStore
{
private readonly Store<RuntimeDbContext, WorkflowExecutionLogRecord> _store;
public EFCoreWorkflowExecutionLogStore(Store<RuntimeDbContext, WorkflowExecutionLogRecord> store) => _store = store;
private readonly Store<RuntimeElsaDbContext, WorkflowExecutionLogRecord> _store;
public EFCoreWorkflowExecutionLogStore(Store<RuntimeElsaDbContext, WorkflowExecutionLogRecord> store) => _store = store;
public async Task SaveAsync(WorkflowExecutionLogRecord record, CancellationToken cancellationToken = default) => await _store.SaveAsync(record, cancellationToken);
public async Task SaveManyAsync(IEnumerable<WorkflowExecutionLogRecord> records, CancellationToken cancellationToken = default) => await _store.SaveManyAsync(records, cancellationToken);

View file

@ -14,11 +14,11 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore
{
private readonly SerializerOptionsProvider _serializerOptionsProvider;
private readonly ISystemClock _systemClock;
private readonly IDbContextFactory<RuntimeDbContext> _dbContextFactory;
private readonly IDbContextFactory<RuntimeElsaDbContext> _dbContextFactory;
public EFCoreWorkflowStateStore(
IDbContextFactory<RuntimeDbContext> dbContextFactory,
Store<RuntimeDbContext, WorkflowState> store,
IDbContextFactory<RuntimeElsaDbContext> dbContextFactory,
Store<RuntimeElsaDbContext, WorkflowState> store,
SerializerOptionsProvider serializerOptionsProvider,
ISystemClock systemClock)
{

View file

@ -8,11 +8,11 @@ namespace Elsa.WorkflowContexts.Extensions;
public static class WorkflowExecutionContextExtensions
{
public static void SetWorkflowContext(this WorkflowExecutionContext workflowExecutionContext, WorkflowContext workflowContext, object value) => workflowExecutionContext.TransientProperties.SetWorkflowContext(workflowContext, value);
public static void SetWorkflowContext(this ExpressionExecutionContext expressionExecutionContext, WorkflowContext workflowContext, object value) => expressionExecutionContext.GetTransientProperties().SetWorkflowContext(workflowContext, value);
public static void SetWorkflowContext(this ExpressionExecutionContext expressionExecutionContext, WorkflowContext workflowContext, object value) => expressionExecutionContext.GetWorkflowExecutionContext().TransientProperties.SetWorkflowContext(workflowContext, value);
public static T? GetWorkflowContext<T, TProvider>(this WorkflowExecutionContext workflowExecutionContext) => (T?)workflowExecutionContext.TransientProperties.GetWorkflowContextByProviderType(typeof(TProvider));
public static T? GetWorkflowContext<T, TProvider>(this ExpressionExecutionContext expressionExecutionContext) => (T?)expressionExecutionContext.GetTransientProperties().GetWorkflowContextByProviderType(typeof(TProvider));
public static T? GetWorkflowContext<T, TProvider>(this ExpressionExecutionContext expressionExecutionContext) => (T?)expressionExecutionContext.GetWorkflowExecutionContext().TransientProperties.GetWorkflowContextByProviderType(typeof(TProvider));
public static object? GetWorkflowContext(this WorkflowExecutionContext workflowExecutionContext, WorkflowContext workflowContext) => workflowExecutionContext.TransientProperties.GetWorkflowContext(workflowContext);
public static object? GetWorkflowContext(this ExpressionExecutionContext expressionExecutionContext, WorkflowContext workflowContext) => expressionExecutionContext.GetTransientProperties().GetWorkflowContext(workflowContext);
public static object? GetWorkflowContext(this ExpressionExecutionContext expressionExecutionContext, WorkflowContext workflowContext) => expressionExecutionContext.GetWorkflowExecutionContext().TransientProperties.GetWorkflowContext(workflowContext);
private static void SetWorkflowContext(this IDictionary<object, object> transientProperties, WorkflowContext workflowContext, object value)
{

View file

@ -22,7 +22,9 @@ public class WorkflowContext<T, TProvider> : WorkflowContext where TProvider:IWo
public T? Get(ExpressionExecutionContext context)
{
var workflowContexts = (IDictionary<WorkflowContext, object?>)context.GetTransientProperties()["WorkflowContexts"]!;
var workflowExecutionContext = context.GetWorkflowExecutionContext();
var transientProperties = workflowExecutionContext.TransientProperties;
var workflowContexts = (IDictionary<WorkflowContext, object?>)transientProperties["WorkflowContexts"]!;
return workflowContexts.TryGetValue(this, out var workflowContext) ? (T?)workflowContext : default;
}
}

View file

@ -5,21 +5,27 @@ namespace Elsa.Workflows.Core;
public static class ExpressionExecutionContextExtensions
{
public static readonly object WorkflowKey = new();
public static readonly object TransientPropertiesKey = new();
public static readonly object WorkflowExecutionContextKey = new();
public static readonly object InputKey = new();
public static readonly object WorkflowKey = new();
public static IDictionary<object, object> CreateApplicationPropertiesFrom(Workflow workflow, IDictionary<object, object> transientProperties, IDictionary<string, object> input) =>
public static IDictionary<object, object> CreateActivityExecutionContextPropertiesFrom(WorkflowExecutionContext workflowExecutionContext, IDictionary<string, object> input) =>
new Dictionary<object, object>
{
[WorkflowExecutionContextKey] = workflowExecutionContext,
[InputKey] = input,
[WorkflowKey] = workflowExecutionContext.Workflow,
};
public static IDictionary<object, object> CreateTriggerIndexingPropertiesFrom(Workflow workflow, IDictionary<string, object> input) =>
new Dictionary<object, object>
{
[WorkflowKey] = workflow,
[TransientPropertiesKey] = transientProperties,
[InputKey] = input
};
public static Workflow GetWorkflow(this ExpressionExecutionContext context) => (Workflow)context.ApplicationProperties[WorkflowKey];
public static IDictionary<object, object> GetTransientProperties(this ExpressionExecutionContext context) => (IDictionary<object, object>)context.ApplicationProperties[TransientPropertiesKey];
public static IDictionary<string, object> GetInput(this ExpressionExecutionContext context) => (IDictionary<string, object>)context.ApplicationProperties[InputKey];
public static WorkflowExecutionContext GetWorkflowExecutionContext(this ExpressionExecutionContext context) => (WorkflowExecutionContext)context.TransientProperties[WorkflowExecutionContextKey];
public static IDictionary<string, object> GetInput(this ExpressionExecutionContext context) => (IDictionary<string, object>)context.TransientProperties[InputKey];
public static T? Get<T>(this ExpressionExecutionContext context, Input<T>? input) => input != null ? (T?)context.GetBlock(input.MemoryBlockReference).Value : default;
public static T? Get<T>(this ExpressionExecutionContext context, Output output) => (T?)context.GetBlock(output.MemoryBlockReference).Value;
@ -27,7 +33,6 @@ public static class ExpressionExecutionContextExtensions
public static T? GetVariable<T>(this ExpressionExecutionContext context, string name) => (T?)context.GetVariable(name);
public static T? GetVariable<T>(this ExpressionExecutionContext context) => (T?)context.GetVariable(typeof(T).Name);
public static object? GetVariable(this ExpressionExecutionContext context, string name) => new Variable(name).Get(context);
public static Variable SetVariable<T>(this ExpressionExecutionContext context, T? value) => context.SetVariable(typeof(T).Name, value);
public static Variable SetVariable<T>(this ExpressionExecutionContext context, string name, T? value) => context.SetVariable(name, (object?)value);
@ -40,11 +45,6 @@ public static class ExpressionExecutionContextExtensions
public static void Set(this ExpressionExecutionContext context, Output? output, object? value)
{
if(output != null)
context.Set(output.MemoryBlockReference, value);
//var convertedValue = output.ValueConverter?.Invoke(value) ?? value;
//var convertedValue = value;
//var targets = new[] { output.MemoryReference }.Concat(output.Targets);
//foreach (var target in targets) context.Set(target, convertedValue);
if(output != null) context.Set(output.MemoryBlockReference, value);
}
}

View file

@ -141,7 +141,7 @@ public class WorkflowExecutionContext
public ActivityExecutionContext CreateActivityExecutionContext(IActivity activity, ActivityExecutionContext? parentContext = default)
{
var parentExpressionExecutionContext = parentContext?.ExpressionExecutionContext;
var applicationProperties = ExpressionExecutionContextExtensions.CreateApplicationPropertiesFrom(Workflow, TransientProperties, Input);
var applicationProperties = ExpressionExecutionContextExtensions.CreateActivityExecutionContextPropertiesFrom(this, Input);
var parentMemory = parentContext?.ExpressionExecutionContext.Memory ?? MemoryRegister;
var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, parentMemory, parentExpressionExecutionContext, applicationProperties, CancellationToken);
var activityExecutionContext = new ActivityExecutionContext(this, parentContext, expressionExecutionContext, activity, CancellationToken);

View file

@ -159,8 +159,7 @@ public class TriggerIndexer : ITriggerIndexer
var register = context.GetOrCreateRegister(trigger);
var cancellationToken = context.CancellationToken;
var expressionInput = new Dictionary<string, object>();
var transientProperties = new Dictionary<object, object>();
var applicationProperties = ExpressionExecutionContextExtensions.CreateApplicationPropertiesFrom(context.Workflow, transientProperties, expressionInput);
var applicationProperties = ExpressionExecutionContextExtensions.CreateTriggerIndexingPropertiesFrom(context.Workflow, expressionInput);
var expressionExecutionContext = new ExpressionExecutionContext(_serviceProvider, register, default, applicationProperties, cancellationToken);
// Evaluate activity inputs before requesting trigger data.