diff --git a/src/modules/Elsa.Common/Extensions/ServiceCollectionExtensions.cs b/src/modules/Elsa.Common/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 000000000..c5088a123 --- /dev/null +++ b/src/modules/Elsa.Common/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,37 @@ +namespace Elsa.Extensions; + +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; + +public static class ServiceCollectionExtensions +{ + /// + /// Adds the service with a specific implementation type only if the combination + /// of service and implementation does not already exist in the service collection. + /// + public static IServiceCollection TryAddScopedImplementation( + this IServiceCollection services) + where TService : class + where TImplementation : class, TService + { + if (!services.Any(sd => sd.ServiceType == typeof(TService) && sd.ImplementationType == typeof(TImplementation))) + services.AddScoped(); + + return services; + } + + /// + /// Adds the service with a specific implementation factory only if the combination + /// of service and implementation already doesn't exist. + /// + public static IServiceCollection TryAddScopedImplementation( + this IServiceCollection services, Func implementationFactory) + where TService : class + { + if (services.All(sd => sd.ServiceType != typeof(TService))) + services.AddScoped(implementationFactory); + + return services; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextBase.cs b/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextBase.cs index 4e14923f2..5b9b7557b 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextBase.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextBase.cs @@ -18,7 +18,8 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema EntityState.Modified, }; - protected readonly IServiceProvider ServiceProvider; + protected IServiceProvider ServiceProvider { get; } + private readonly ElsaDbContextOptions? _elsaDbContextOptions; public string? TenantId { get; set; } /// @@ -40,10 +41,10 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema protected ElsaDbContextBase(DbContextOptions options, IServiceProvider serviceProvider) : base(options) { ServiceProvider = serviceProvider; - var elsaDbContextOptions = options.FindExtension()?.Options; - + _elsaDbContextOptions = options.FindExtension()?.Options; + // ReSharper disable once VirtualMemberCallInConstructor - Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema; + Schema = !string.IsNullOrWhiteSpace(_elsaDbContextOptions?.SchemaName) ? _elsaDbContextOptions.SchemaName : ElsaSchema; var tenantAccessor = serviceProvider.GetService(); var tenantId = tenantAccessor?.Tenant?.Id; @@ -70,19 +71,19 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - if (!string.IsNullOrWhiteSpace(Schema)) - { + if (!string.IsNullOrWhiteSpace(Schema)) modelBuilder.HasDefaultSchema(Schema); - } + + var additionalConfigurations = _elsaDbContextOptions?.GetModelConfigurations(this); + + additionalConfigurations?.Invoke(modelBuilder); var entityTypeHandlers = ServiceProvider.GetServices().ToList(); foreach (var entityType in modelBuilder.Model.GetEntityTypes().ToList()) { - foreach (var handler in entityTypeHandlers) - { + foreach (var handler in entityTypeHandlers) handler.Handle(this, modelBuilder, entityType); - } } } diff --git a/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextOptions.cs b/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextOptions.cs index ad185a396..cd6af7271 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextOptions.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Common/ElsaDbContextOptions.cs @@ -1,4 +1,5 @@ using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; namespace Elsa.EntityFrameworkCore; @@ -22,4 +23,30 @@ public class ElsaDbContextOptions /// The assembly name containing the migrations. /// public string? MigrationsAssemblyName { get; set; } + + public IDictionary> ProviderSpecificConfigurations { get; set; } = new Dictionary>(); + + public void ConfigureModel(Action configure) where TDbContext : DbContext + { + ConfigureModel(typeof(TDbContext), configure); + } + + public void ConfigureModel(Type dbContextType, Action configure) + { + if (!ProviderSpecificConfigurations.TryGetValue(dbContextType, out var configurations)) + ProviderSpecificConfigurations[dbContextType] = configurations = _ => { }; + + configurations += configure; + ProviderSpecificConfigurations[dbContextType] = configurations; + } + + public Action GetModelConfigurations(DbContext dbContext) + { + return GetModelConfigurations(dbContext.GetType()); + } + + public Action GetModelConfigurations(Type dbContextType) + { + return ProviderSpecificConfigurations.TryGetValue(dbContextType, out var providerConfigurations) ? providerConfigurations : _ => { }; + } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Common/RunMigrationsStartupTask.cs b/src/modules/Elsa.EntityFrameworkCore.Common/RunMigrationsStartupTask.cs index f55e3b647..45f9c4a5e 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Common/RunMigrationsStartupTask.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Common/RunMigrationsStartupTask.cs @@ -16,7 +16,7 @@ public class RunMigrationsStartupTask(IDbContextFactory /// , IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + // In order to use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Property("StringData").HasColumnType("NCLOB"); + builder.Property("Data").HasColumnType("NCLOB"); + builder.Property(x => x.Description).HasColumnType("NCLOB"); + builder.Property(x => x.MaterializerContext).HasColumnType("NCLOB"); + builder.Property(x => x.BinaryData).HasColumnType("BLOB"); + } + + public void Configure(EntityTypeBuilder builder) + { + // In order to use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Property("Data").HasColumnType("NCLOB"); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Configurations/Runtime.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Configurations/Runtime.cs new file mode 100644 index 000000000..20eecc6f5 --- /dev/null +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Configurations/Runtime.cs @@ -0,0 +1,63 @@ +using Elsa.Workflows.Runtime.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Elsa.EntityFrameworkCore.Oracle.Configurations; + +public class Runtime : + IEntityTypeConfiguration, + IEntityTypeConfiguration, + IEntityTypeConfiguration, + IEntityTypeConfiguration, + IEntityTypeConfiguration +{ + /// + public void Configure(EntityTypeBuilder builder) + { + // To use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Property("SerializedActivityState").HasColumnType("NCLOB"); + builder.Property("SerializedException").HasColumnType("NCLOB"); + builder.Property("SerializedPayload").HasColumnType("NCLOB"); + builder.Property("SerializedOutputs").HasColumnType("NCLOB"); + builder.Property("SerializedProperties").HasColumnType("NCLOB"); + } + + /// + public void Configure(EntityTypeBuilder builder) + { + // To use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + // modelBuilder.Entity().Ignore(x => x.Payload); + // modelBuilder.Entity().Ignore(x => x.Metadata); + builder.Property("SerializedPayload").HasColumnType("NCLOB"); + builder.Property("SerializedMetadata").HasColumnType("NCLOB"); + } + + /// + public void Configure(EntityTypeBuilder builder) + { + // To use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Property("SerializedPayload").HasColumnType("NCLOB"); + } + + /// + public void Configure(EntityTypeBuilder builder) + { + // To use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Property("SerializedActivityState").HasColumnType("NCLOB"); + builder.Property("SerializedPayload").HasColumnType("NCLOB"); + } + + public void Configure(EntityTypeBuilder builder) + { + // To use data more than 2000 char we have to use NCLOB. + // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). + builder.Ignore(x => x.Input); + builder.Ignore(x => x.BookmarkPayload); + builder.Property("SerializedInput").HasColumnType("NCLOB"); + builder.Property("SerializedBookmarkPayload").HasColumnType("NCLOB"); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextFactories.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextFactories.cs index 6270c9d91..d2fa8f28f 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextFactories.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextFactories.cs @@ -35,6 +35,7 @@ public class OracleDesignTimeDbContextFactory : DesignTimeDbContextF { protected override void ConfigureBuilder(DbContextOptionsBuilder builder, string connectionString) { - builder.UseElsaOracle(GetType().Assembly, connectionString); + var options = new ElsaDbContextOptions().Configure(); + builder.UseElsaOracle(GetType().Assembly, connectionString, options); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextOptionsBuilder.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextOptionsBuilder.cs index 1aa7e716d..f35133910 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextOptionsBuilder.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextOptionsBuilder.cs @@ -13,7 +13,7 @@ public static class DbContextOptionsBuilderExtensions /// /// Configures Entity Framework Core with Oracle. /// - public static DbContextOptionsBuilder UseElsaOracle(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = default, Action? configure = default) => + public static DbContextOptionsBuilder UseElsaOracle(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = null, Action? configure = null) => builder .UseElsaDbContextOptions(options) .UseOracle(connectionString, db => diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Elsa.EntityFrameworkCore.Oracle.csproj b/src/modules/Elsa.EntityFrameworkCore.Oracle/Elsa.EntityFrameworkCore.Oracle.csproj index c4ecf6716..662dab74a 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Elsa.EntityFrameworkCore.Oracle.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Elsa.EntityFrameworkCore.Oracle.csproj @@ -20,5 +20,12 @@ + + + + + + + diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20241212211620_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20250131233442_V3_3.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20241212211620_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20250131233442_V3_3.Designer.cs index 812a1ef52..c16d8aac2 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20241212211620_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20250131233442_V3_3.Designer.cs @@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations { [DbContext(typeof(AlterationsElsaDbContext))] - [Migration("20241212211620_V3_3")] + [Migration("20250131233442_V3_3")] partial class V3_3 { /// @@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20241212211620_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20250131233442_V3_3.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20241212211620_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/20250131233442_V3_3.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/AlterationsElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/AlterationsElsaDbContextModelSnapshot.cs index 7a7b4f739..617db1282 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/AlterationsElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Alterations/AlterationsElsaDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Alterations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.Designer.cs index 5948fc317..9b9a8c12d 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.Designer.cs @@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity { [DbContext(typeof(IdentityElsaDbContext))] - [Migration("20241212211936_V3_3")] + [Migration("20250131233455_V3_3")] partial class V3_3 { /// @@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.cs similarity index 99% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.cs index f9c5d3188..37d23e329 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20241212211936_V3_3.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/20250131233455_V3_3.cs @@ -19,7 +19,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( - name: _schema.Schema); + _schema.Schema); migrationBuilder.CreateTable( name: "Applications", diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/IdentityElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/IdentityElsaDbContextModelSnapshot.cs index 6b6a40e5a..aabcce6cb 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/IdentityElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Identity/IdentityElsaDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Identity #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.Designer.cs index d87cdc60c..8f95ac067 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.Designer.cs @@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels { [DbContext(typeof(LabelsElsaDbContext))] - [Migration("20241212212100_V3_3")] + [Migration("20250131233459_V3_3")] partial class V3_3 { /// @@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.cs index af7faf037..414471594 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20241212212100_V3_3.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/20250131233459_V3_3.cs @@ -19,7 +19,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( - name: _schema.Schema); + _schema.Schema); migrationBuilder.CreateTable( name: "Labels", diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs index 8ff391a49..6d050f7c2 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Labels/LabelsElsaDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Labels #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.Designer.cs similarity index 91% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.Designer.cs index 018b9a4d1..1e05309c4 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.Designer.cs @@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20241212211817_V3_3")] + [Migration("20250131233451_V3_3")] partial class V3_3 { /// @@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -32,35 +32,35 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(450)"); b.Property("BinaryData") - .HasColumnType("RAW(2000)"); + .HasColumnType("BLOB"); b.Property("CreatedAt") .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); b.Property("Data") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("DefinitionId") .IsRequired() .HasColumnType("NVARCHAR2(450)"); b.Property("Description") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("IsLatest") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsPublished") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsReadonly") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsSystem") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("MaterializerContext") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("MaterializerName") .IsRequired() @@ -73,7 +73,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(2000)"); b.Property("StringData") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -82,7 +82,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(2000)"); b.Property("UsableAsActivity") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("Version") .HasColumnType("NUMBER(10)"); @@ -129,7 +129,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); b.Property("Data") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("DataCompressionAlgorithm") .HasColumnType("NVARCHAR2(2000)"); @@ -149,7 +149,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NUMBER(10)"); b.Property("IsSystem") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("Name") .HasColumnType("NVARCHAR2(450)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.cs similarity index 90% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.cs index e3ba33c57..aa899af2c 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20241212211817_V3_3.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/20250131233451_V3_3.cs @@ -30,22 +30,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management Id = table.Column(type: "NVARCHAR2(450)", nullable: false), DefinitionId = table.Column(type: "NVARCHAR2(450)", nullable: false), Name = table.Column(type: "NVARCHAR2(450)", nullable: true), - Description = table.Column(type: "NVARCHAR2(2000)", nullable: true), + Description = table.Column(type: "NCLOB", nullable: true), ToolVersion = table.Column(type: "NVARCHAR2(2000)", nullable: true), ProviderName = table.Column(type: "NVARCHAR2(2000)", nullable: true), MaterializerName = table.Column(type: "NVARCHAR2(2000)", nullable: false), - MaterializerContext = table.Column(type: "NVARCHAR2(2000)", nullable: true), - StringData = table.Column(type: "NVARCHAR2(2000)", nullable: true), - BinaryData = table.Column(type: "RAW(2000)", nullable: true), - IsReadonly = table.Column(type: "NUMBER(1)", nullable: false), - IsSystem = table.Column(type: "NUMBER(1)", nullable: false), - Data = table.Column(type: "NVARCHAR2(2000)", nullable: true), - UsableAsActivity = table.Column(type: "NUMBER(1)", nullable: true), + MaterializerContext = table.Column(type: "NCLOB", nullable: true), + StringData = table.Column(type: "NCLOB", nullable: true), + BinaryData = table.Column(type: "BLOB", nullable: true), + IsReadonly = table.Column(type: "BOOLEAN", nullable: false), + IsSystem = table.Column(type: "BOOLEAN", nullable: false), + Data = table.Column(type: "NCLOB", nullable: true), + UsableAsActivity = table.Column(type: "BOOLEAN", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true), CreatedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), Version = table.Column(type: "NUMBER(10)", nullable: false), - IsLatest = table.Column(type: "NUMBER(1)", nullable: false), - IsPublished = table.Column(type: "NUMBER(1)", nullable: false) + IsLatest = table.Column(type: "BOOLEAN", nullable: false), + IsPublished = table.Column(type: "BOOLEAN", nullable: false) }, constraints: table => { @@ -67,11 +67,11 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management CorrelationId = table.Column(type: "NVARCHAR2(450)", nullable: true), Name = table.Column(type: "NVARCHAR2(450)", nullable: true), IncidentCount = table.Column(type: "NUMBER(10)", nullable: false), - IsSystem = table.Column(type: "NUMBER(1)", nullable: false), + IsSystem = table.Column(type: "BOOLEAN", nullable: false), CreatedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), UpdatedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), FinishedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: true), - Data = table.Column(type: "NVARCHAR2(2000)", nullable: true), + Data = table.Column(type: "NCLOB", nullable: true), DataCompressionAlgorithm = table.Column(type: "NVARCHAR2(2000)", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true) }, diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index d28aebf43..325fa4f68 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -29,35 +29,35 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(450)"); b.Property("BinaryData") - .HasColumnType("RAW(2000)"); + .HasColumnType("BLOB"); b.Property("CreatedAt") .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); b.Property("Data") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("DefinitionId") .IsRequired() .HasColumnType("NVARCHAR2(450)"); b.Property("Description") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("IsLatest") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsPublished") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsReadonly") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("IsSystem") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("MaterializerContext") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("MaterializerName") .IsRequired() @@ -70,7 +70,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(2000)"); b.Property("StringData") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -79,7 +79,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NVARCHAR2(2000)"); b.Property("UsableAsActivity") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("Version") .HasColumnType("NUMBER(10)"); @@ -126,7 +126,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); b.Property("Data") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("DataCompressionAlgorithm") .HasColumnType("NVARCHAR2(2000)"); @@ -146,7 +146,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Management .HasColumnType("NUMBER(10)"); b.Property("IsSystem") - .HasColumnType("NUMBER(1)"); + .HasColumnType("BOOLEAN"); b.Property("Name") .HasColumnType("NVARCHAR2(450)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.Designer.cs similarity index 95% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.Designer.cs index 3abc3e068..d7fd0359e 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.Designer.cs @@ -12,7 +12,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime { [DbContext(typeof(RuntimeElsaDbContext))] - [Migration("20250116193207_V3_3")] + [Migration("20250131233446_V3_3")] partial class V3_3 { /// @@ -21,7 +21,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -75,22 +75,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("BOOLEAN"); b.Property("SerializedActivityState") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedActivityStateCompressionAlgorithm") .HasColumnType("NVARCHAR2(2000)"); b.Property("SerializedException") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedOutputs") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedProperties") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("StartedAt") .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); @@ -223,10 +223,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedMetadata") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -273,7 +273,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -346,10 +346,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NUMBER(19)"); b.Property("SerializedActivityState") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("Source") .HasColumnType("NVARCHAR2(2000)"); @@ -457,10 +457,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedBookmarkPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedInput") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(2000)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.cs index 133e73074..c470348e0 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250116193207_V3_3.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/20250131233446_V3_3.cs @@ -38,12 +38,12 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime HasBookmarks = table.Column(type: "BOOLEAN", nullable: false), Status = table.Column(type: "NVARCHAR2(450)", nullable: false), CompletedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: true), - SerializedActivityState = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedActivityState = table.Column(type: "NCLOB", nullable: true), SerializedActivityStateCompressionAlgorithm = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedException = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedOutputs = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedPayload = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedProperties = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedException = table.Column(type: "NCLOB", nullable: true), + SerializedOutputs = table.Column(type: "NCLOB", nullable: true), + SerializedPayload = table.Column(type: "NCLOB", nullable: true), + SerializedProperties = table.Column(type: "NCLOB", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true) }, constraints: table => @@ -84,8 +84,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime ActivityInstanceId = table.Column(type: "NVARCHAR2(450)", nullable: true), CorrelationId = table.Column(type: "NVARCHAR2(2000)", nullable: true), CreatedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), - SerializedMetadata = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedPayload = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedMetadata = table.Column(type: "NCLOB", nullable: true), + SerializedPayload = table.Column(type: "NCLOB", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true) }, constraints: table => @@ -118,7 +118,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime Name = table.Column(type: "NVARCHAR2(450)", nullable: false), ActivityId = table.Column(type: "NVARCHAR2(2000)", nullable: false), Hash = table.Column(type: "NVARCHAR2(450)", nullable: true), - SerializedPayload = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedPayload = table.Column(type: "NCLOB", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true) }, constraints: table => @@ -148,8 +148,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime EventName = table.Column(type: "NVARCHAR2(450)", nullable: true), Message = table.Column(type: "NVARCHAR2(2000)", nullable: true), Source = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedActivityState = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedPayload = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedActivityState = table.Column(type: "NCLOB", nullable: true), + SerializedPayload = table.Column(type: "NCLOB", nullable: true), TenantId = table.Column(type: "NVARCHAR2(450)", nullable: true) }, constraints: table => @@ -170,8 +170,8 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime ActivityInstanceId = table.Column(type: "NVARCHAR2(450)", nullable: true), CreatedAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), ExpiresAt = table.Column(type: "TIMESTAMP(7) WITH TIME ZONE", nullable: false), - SerializedBookmarkPayload = table.Column(type: "NVARCHAR2(2000)", nullable: true), - SerializedInput = table.Column(type: "NVARCHAR2(2000)", nullable: true), + SerializedBookmarkPayload = table.Column(type: "NCLOB", nullable: true), + SerializedInput = table.Column(type: "NCLOB", nullable: true), TenantId = table.Column(type: "NVARCHAR2(2000)", nullable: true) }, constraints: table => diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs index 5e1520286..e0adad632 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Runtime/RuntimeElsaDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -72,22 +72,22 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("BOOLEAN"); b.Property("SerializedActivityState") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedActivityStateCompressionAlgorithm") .HasColumnType("NVARCHAR2(2000)"); b.Property("SerializedException") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedOutputs") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedProperties") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("StartedAt") .HasColumnType("TIMESTAMP(7) WITH TIME ZONE"); @@ -220,10 +220,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedMetadata") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -270,7 +270,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(450)"); @@ -343,10 +343,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NUMBER(19)"); b.Property("SerializedActivityState") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("Source") .HasColumnType("NVARCHAR2(2000)"); @@ -454,10 +454,10 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Runtime .HasColumnType("NVARCHAR2(450)"); b.Property("SerializedBookmarkPayload") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("SerializedInput") - .HasColumnType("NVARCHAR2(2000)"); + .HasColumnType("NCLOB"); b.Property("TenantId") .HasColumnType("NVARCHAR2(2000)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20241212212227_V3_3.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20250131233503_V3_3.Designer.cs similarity index 94% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20241212212227_V3_3.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20250131233503_V3_3.Designer.cs index a02ded2ad..447cd1eac 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20241212212227_V3_3.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20250131233503_V3_3.Designer.cs @@ -11,7 +11,7 @@ using Oracle.EntityFrameworkCore.Metadata; namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants { [DbContext(typeof(TenantsElsaDbContext))] - [Migration("20241212212227_V3_3")] + [Migration("20250131233503_V3_3")] partial class V3_3 { /// @@ -20,7 +20,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20241212212227_V3_3.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20250131233503_V3_3.cs similarity index 100% rename from src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20241212212227_V3_3.cs rename to src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/20250131233503_V3_3.cs diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/TenantsElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/TenantsElsaDbContextModelSnapshot.cs index 464fe8f3f..79041524c 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/TenantsElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/Migrations/Tenants/TenantsElsaDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace Elsa.EntityFrameworkCore.Oracle.Migrations.Tenants #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Elsa") - .HasAnnotation("ProductVersion", "7.0.20") + .HasAnnotation("ProductVersion", "8.0.12") .HasAnnotation("Relational:MaxIdentifierLength", 128); OracleModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/OracleProvidersExtensions.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/OracleProvidersExtensions.cs index 191a08eb2..8d800c577 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/OracleProvidersExtensions.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Oracle/OracleProvidersExtensions.cs @@ -1,10 +1,10 @@ using System.Reflection; -using Elsa.EntityFrameworkCore.Modules.Alterations; -using Elsa.EntityFrameworkCore.Oracle; -using Elsa.Extensions; +using Elsa.EntityFrameworkCore.Modules.Management; +using Elsa.EntityFrameworkCore.Modules.Runtime; +using Elsa.EntityFrameworkCore.Oracle.Configurations; +using Elsa.Workflows.Management.Entities; +using Elsa.Workflows.Runtime.Entities; using JetBrains.Annotations; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Oracle.EntityFrameworkCore.Infrastructure; // ReSharper disable once CheckNamespace @@ -60,11 +60,28 @@ public static class OracleProvidersExtensions where TDbContext : ElsaDbContextBase where TFeature : PersistenceFeatureBase { - feature.Services.TryAddScopedImplementation(); - feature.Services.TryAddScopedImplementation(); - feature.Services.TryAddScopedImplementation(); - + options ??= new(); + options.Configure(); feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaOracle(migrationsAssembly, connectionStringFunc(sp), options, configure: configure); return (TFeature)feature; } + + public static ElsaDbContextOptions Configure(this ElsaDbContextOptions options) + { + var management = new Management(); + var runtime = new Runtime(); + + options.ConfigureModel(modelBuilder => modelBuilder + .ApplyConfiguration(management) + .ApplyConfiguration(management)); + + options.ConfigureModel(modelBuilder => modelBuilder + .ApplyConfiguration(runtime) + .ApplyConfiguration(runtime) + .ApplyConfiguration(runtime) + .ApplyConfiguration(runtime) + .ApplyConfiguration(runtime)); + + return options; + } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForAlterations.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForAlterations.cs deleted file mode 100644 index 81dc4bff3..000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForAlterations.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Elsa.Alterations.Core.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; - -namespace Elsa.EntityFrameworkCore.Oracle; - -/// -/// Represents a class that handles entity model creation for SQLite databases. -/// -public class SetupForAlterations : IEntityModelCreatingHandler -{ - /// - public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType) - { - if(!dbContext.Database.IsOracle()) - return; - - // In order to use data more than 2000 char we have to use NCLOB. - // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). - modelBuilder.Entity().Ignore(x => x.Alterations); - modelBuilder.Entity().Ignore(x => x.WorkflowInstanceFilter); - modelBuilder.Entity().Property("SerializedAlterations").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedWorkflowInstanceFilter").HasColumnType("NCLOB"); - modelBuilder.Entity().Ignore(x => x.Log); - modelBuilder.Entity().Property("SerializedLog").HasColumnType("NCLOB"); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForManagement.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForManagement.cs deleted file mode 100644 index c7ba3e7bb..000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForManagement.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq.Expressions; -using Elsa.Workflows.Management.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; - -namespace Elsa.EntityFrameworkCore.Oracle; - -/// -/// Represents a class that handles entity model creation for SQLite databases. -/// -public class SetupForManagement : IEntityModelCreatingHandler -{ - private static Expression> VersionToStringConverter => v => v != null ? v.ToString() : null; - private static Expression> StringToVersionConverter => v => v != null ? Version.Parse(v) : null; - - /// - public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType) - { - if(!dbContext.Database.IsOracle()) - return; - - // In order to use data more than 2000 char we have to use NCLOB. - // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). - modelBuilder.Entity().Property("Data").HasColumnType("NCLOB"); - modelBuilder.Entity().Ignore(x => x.WorkflowState); - modelBuilder.Entity().Ignore(x => x.CustomProperties); - modelBuilder.Entity().Ignore(x => x.Variables); - modelBuilder.Entity().Ignore(x => x.Inputs); - modelBuilder.Entity().Ignore(x => x.Outputs); - modelBuilder.Entity().Ignore(x => x.Outcomes); - modelBuilder.Entity().Ignore(x => x.Options); - modelBuilder.Entity().Property(x => x.ToolVersion).HasConversion(VersionToStringConverter, StringToVersionConverter); - modelBuilder.Entity().Property("StringData").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("Data").HasColumnType("NCLOB"); - modelBuilder.Entity().Property(x => x.Description).HasColumnType("NCLOB"); - modelBuilder.Entity().Property(x => x.MaterializerContext).HasColumnType("NCLOB"); - modelBuilder.Entity().Property(x => x.BinaryData).HasColumnType("BLOB"); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForRuntime.cs b/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForRuntime.cs deleted file mode 100644 index 1ccab2951..000000000 --- a/src/modules/Elsa.EntityFrameworkCore.Oracle/SetupForRuntime.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Elsa.KeyValues.Entities; -using Elsa.Workflows.Runtime.Entities; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; - -namespace Elsa.EntityFrameworkCore.Oracle; - -/// -/// Represents a class that handles entity model creation for SQLite databases. -/// -public class SetupForRuntime : IEntityModelCreatingHandler -{ - /// - public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType) - { - if (!dbContext.Database.IsOracle()) - return; - - // To use data more than 2000 char we have to use NCLOB. - // In Oracle, we have to explicitly say the column is NCLOB otherwise it would be considered nvarchar(2000). - modelBuilder.Entity().Property("SerializedPayload").HasColumnType("NCLOB"); - - modelBuilder.Entity().Ignore(x => x.ActivityState); - modelBuilder.Entity().Ignore(x => x.Payload); - modelBuilder.Entity().Property("SerializedActivityState").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedPayload").HasColumnType("NCLOB"); - - modelBuilder.Entity().Ignore(x => x.ActivityState); - modelBuilder.Entity().Ignore(x => x.Exception); - modelBuilder.Entity().Ignore(x => x.Payload); - modelBuilder.Entity().Ignore(x => x.Outputs); - modelBuilder.Entity().Ignore(x => x.Properties); - modelBuilder.Entity().Property("SerializedActivityState").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedException").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedPayload").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedOutputs").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedProperties").HasColumnType("NCLOB"); - - modelBuilder.Entity().Ignore(x => x.Payload); - modelBuilder.Entity().Ignore(x => x.Metadata); - modelBuilder.Entity().Property("SerializedPayload").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedMetadata").HasColumnType("NCLOB"); - - modelBuilder.Entity().Ignore(x => x.Payload); - modelBuilder.Entity().Property("SerializedPayload").HasColumnType("NCLOB"); - - modelBuilder.Entity().Ignore(x => x.Input); - modelBuilder.Entity().Ignore(x => x.BookmarkPayload); - modelBuilder.Entity().Property("SerializedInput").HasColumnType("NCLOB"); - modelBuilder.Entity().Property("SerializedBookmarkPayload").HasColumnType("NCLOB"); - - modelBuilder.Entity().Property("SerializedValue").HasColumnType("NCLOB"); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/DbContext.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/DbContext.cs index c6a2ccf06..21e5a43fc 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/DbContext.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Identity/DbContext.cs @@ -31,11 +31,11 @@ public class IdentityElsaDbContext : ElsaDbContextBase /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - base.OnModelCreating(modelBuilder); - var config = new Configurations(); modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); + + base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/DbContext.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/DbContext.cs index f0ae46821..79ab138fb 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/DbContext.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/DbContext.cs @@ -28,12 +28,13 @@ public class ManagementElsaDbContext : ElsaDbContextBase /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - base.OnModelCreating(modelBuilder); modelBuilder.Ignore(); modelBuilder.Ignore(); var config = new Configurations(); modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); + + base.OnModelCreating(modelBuilder); } } diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DbContext.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DbContext.cs index 8977b797f..c03030bf1 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DbContext.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/DbContext.cs @@ -57,8 +57,6 @@ public class RuntimeElsaDbContext : ElsaDbContextBase /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - base.OnModelCreating(modelBuilder); - var config = new Configurations(); modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); @@ -67,5 +65,7 @@ public class RuntimeElsaDbContext : ElsaDbContextBase modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); modelBuilder.ApplyConfiguration(config); + + base.OnModelCreating(modelBuilder); } } \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Tenants/DbContext.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Tenants/DbContext.cs index 90d4dad28..aaa6b23ac 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Tenants/DbContext.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Tenants/DbContext.cs @@ -19,7 +19,7 @@ public class TenantsElsaDbContext : ElsaDbContextBase /// /// The alteration plans. /// - public DbSet Tenants { get; set; } = default!; + public DbSet Tenants { get; set; } = null!; /// protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/src/modules/Elsa.Workflows.Runtime/Entities/BookmarkQueueItem.cs b/src/modules/Elsa.Workflows.Runtime/Entities/BookmarkQueueItem.cs index a39d1feae..f7a867f73 100644 --- a/src/modules/Elsa.Workflows.Runtime/Entities/BookmarkQueueItem.cs +++ b/src/modules/Elsa.Workflows.Runtime/Entities/BookmarkQueueItem.cs @@ -54,7 +54,7 @@ public class BookmarkQueueItem : Entity /// public BookmarkFilter CreateBookmarkFilter() { - return new BookmarkFilter + return new() { WorkflowInstanceId = WorkflowInstanceId, CorrelationId = CorrelationId,