Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core Oracle provider #5637

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageVersion Include="Npgsql" Version="7.0.7" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.18" />
<PackageVersion Include="Oracle.EntityFrameworkCore" Version="7.21.9" />
<PackageVersion Include="Polly" Version="7.2.4" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.4" />
Expand Down Expand Up @@ -164,6 +165,7 @@
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Npgsql" Version="8.0.3" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageVersion Include="Oracle.EntityFrameworkCore" Version="8.21.121" />
<PackageVersion Include="Polly" Version="8.4.0" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageVersion Include="System.Text.Json" Version="8.0.3" />
Expand Down
7 changes: 7 additions & 0 deletions Elsa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Quartz.EntityFramework
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Quartz.EntityFrameworkCore.PostgreSql", "src\modules\Elsa.Quartz.EntityFrameworkCore.PostgreSql\Elsa.Quartz.EntityFrameworkCore.PostgreSql.csproj", "{CCCCEF8C-7D96-4BEA-B9D0-E91EDF08E65D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.Oracle", "src\modules\Elsa.EntityFrameworkCore.Oracle\Elsa.EntityFrameworkCore.Oracle.csproj", "{49D8D2CF-AF68-40FA-951F-018247C97443}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.FileStorage", "src\modules\Elsa.FileStorage\Elsa.FileStorage.csproj", "{732BF088-6AD7-4C4D-9A48-8074253596D4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "storage", "storage", "{B818988E-639C-4E6E-85C1-B231BCAD9DAB}"
Expand Down Expand Up @@ -746,6 +748,10 @@ Global
{CCCCEF8C-7D96-4BEA-B9D0-E91EDF08E65D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCCCEF8C-7D96-4BEA-B9D0-E91EDF08E65D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCCCEF8C-7D96-4BEA-B9D0-E91EDF08E65D}.Release|Any CPU.Build.0 = Release|Any CPU
{49D8D2CF-AF68-40FA-951F-018247C97443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49D8D2CF-AF68-40FA-951F-018247C97443}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49D8D2CF-AF68-40FA-951F-018247C97443}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49D8D2CF-AF68-40FA-951F-018247C97443}.Release|Any CPU.Build.0 = Release|Any CPU
{732BF088-6AD7-4C4D-9A48-8074253596D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{732BF088-6AD7-4C4D-9A48-8074253596D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{732BF088-6AD7-4C4D-9A48-8074253596D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -989,6 +995,7 @@ Global
{05F3B23E-CF28-467B-AD3C-595EA4ED6B96} = {AB797AF0-C12C-46DE-A157-7E25625C6200}
{74ACD9D0-8B4C-42FA-A582-E93BF0075023} = {AB797AF0-C12C-46DE-A157-7E25625C6200}
{CCCCEF8C-7D96-4BEA-B9D0-E91EDF08E65D} = {AB797AF0-C12C-46DE-A157-7E25625C6200}
{49D8D2CF-AF68-40FA-951F-018247C97443} = {9B4F139F-7D26-435C-A561-89E65A67A8E5}
{732BF088-6AD7-4C4D-9A48-8074253596D4} = {B818988E-639C-4E6E-85C1-B231BCAD9DAB}
{B818988E-639C-4E6E-85C1-B231BCAD9DAB} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{29638A67-E79F-44FE-AC05-DA499EBA929E} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
Expand Down
2 changes: 1 addition & 1 deletion migrations/efcore-3.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mods=("Alterations" "Runtime" "Management" "Identity" "Labels")

# Define the list of providers
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql" "Oracle")

# Connection strings for each provider
typeset -A connStrings
Expand Down
2 changes: 1 addition & 1 deletion migrations/efcore-3.1-sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mods=("Alterations" "Runtime" "Management" "Identity")

# Define the list of providers
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql" "Oracle")

# Loop through each module
for module in "${mods[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion migrations/efcore-3.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mods=("Alterations" "Runtime" "Management" "Identity" "Labels")

# Define the list of providers
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql" "Oracle")

# Loop through each module
for module in "${mods[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion migrations/efcore-3.2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mods=("Alterations" "Runtime" "Management" "Identity" "Labels")

# Define the list of providers
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql" "Oracle")

# Loop through each module
for module in "${mods[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion migrations/efcore-3.3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mods=("Alterations" "Runtime" "Management" "Identity" "Labels")

# Define the list of providers
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql")
providers=("MySql" "SqlServer" "Sqlite" "PostgreSql" "Oracle")

# Loop through each module
for module in "${mods[@]}"; do
Expand Down
46 changes: 46 additions & 0 deletions src/modules/Elsa.EntityFrameworkCore.Oracle/DbContextFactories.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Elsa.EntityFrameworkCore.Common.Abstractions;
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Alterations;
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace Elsa.EntityFrameworkCore.Oracle;

[UsedImplicitly]
public class IdentityDbContextFactory : OracleDesignTimeDbContextFactory<IdentityElsaDbContext>
{
}

[UsedImplicitly]
public class ManagementDbContextFactory : OracleDesignTimeDbContextFactory<ManagementElsaDbContext>
{
}

[UsedImplicitly]
public class RuntimeDbContextFactory : OracleDesignTimeDbContextFactory<RuntimeElsaDbContext>
{
}

[UsedImplicitly]
public class LabelsDbContextFactory : OracleDesignTimeDbContextFactory<LabelsElsaDbContext>
{
}

[UsedImplicitly]
public class AlterationsDbContextFactories : OracleDesignTimeDbContextFactory<AlterationsElsaDbContext>
{
}

public class OracleDesignTimeDbContextFactory<TDbContext> : DesignTimeDbContextFactoryBase<TDbContext> where TDbContext : DbContext
{
protected override void ConfigureBuilder(DbContextOptionsBuilder<TDbContext> builder, string connectionString)
{
builder.UseElsaOracle(GetType().Assembly, connectionString);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Reflection;
using Elsa.EntityFrameworkCore.Common;
using Microsoft.EntityFrameworkCore;
using Oracle.EntityFrameworkCore.Infrastructure;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

/// <summary>
/// Contains extension methods for <see cref="DbContextOptionsBuilder"/>.
/// </summary>
public static class DbContextOptionsBuilderExtensions
{
/// <summary>
/// Configures Entity Framework Core with Oracle.
/// </summary>
public static DbContextOptionsBuilder UseElsaOracle(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = default, Action<OracleDbContextOptionsBuilder>? configure = default) =>
builder
.UseElsaDbContextOptions(options)
.UseOracle(connectionString, db =>
{
db
.MigrationsAssembly(options.GetMigrationsAssemblyName(migrationsAssembly))
.MigrationsHistoryTable(options.GetMigrationsHistoryTableName(), options.GetSchemaName());

configure?.Invoke(db);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>
Provides Oracle EF Core migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore oracle</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" PrivateAssets="all" />
<PackageReference Include="Oracle.EntityFrameworkCore" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
</ItemGroup>

</Project>
81 changes: 81 additions & 0 deletions src/modules/Elsa.EntityFrameworkCore.Oracle/Features.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System.Reflection;
using Elsa.EntityFrameworkCore.Common;
using Elsa.EntityFrameworkCore.Modules.Alterations;
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Modules.Labels;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

/// <summary>
/// Provides extensions to configure EF Core to use Oracle.
/// </summary>
public static class OracleProvidersExtensions
{
private static Assembly Assembly => typeof(OracleProvidersExtensions).Assembly;

/// <summary>
/// Configures the <see cref="EFCoreIdentityPersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreIdentityPersistenceFeature UseOracle(this EFCoreIdentityPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="EFCoreAlterationsPersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreAlterationsPersistenceFeature UseOracle(this EFCoreAlterationsPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="EFCoreLabelPersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreLabelPersistenceFeature UseOracle(this EFCoreLabelPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="EFCoreWorkflowDefinitionPersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreWorkflowDefinitionPersistenceFeature UseOracle(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="EFCoreWorkflowInstancePersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreWorkflowInstancePersistenceFeature UseOracle(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="WorkflowManagementPersistenceFeature"/> to use Oracle.
/// </summary>
public static WorkflowManagementPersistenceFeature UseOracle(this WorkflowManagementPersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}

/// <summary>
/// Configures the <see cref="EFCoreWorkflowRuntimePersistenceFeature"/> to use Oracle.
/// </summary>
public static EFCoreWorkflowRuntimePersistenceFeature UseOracle(this EFCoreWorkflowRuntimePersistenceFeature feature, string connectionString, ElsaDbContextOptions? options = default)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaOracle(Assembly, connectionString, options);
return feature;
}
}
3 changes: 3 additions & 0 deletions src/modules/Elsa.EntityFrameworkCore.Oracle/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>
Loading
Loading