* Restore EF Core persistence layer Originally, we had moved EF Core to the extensions repo, but in practice this turned out to be rather impractical when debugging elsa-core, given that we would lose all of the state (workflow definitions, instances, etc.) across application restarts. * Integrate PostgreSQL support into EF Core persistence and enhance BlobStorage workflows provider setup.
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
using System.Reflection;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace Elsa.Persistence.EFCore.Extensions;
|
|
|
|
/// <summary>
|
|
/// Contains extension methods for <see cref="DbContextOptionsBuilder"/>.
|
|
/// </summary>
|
|
public static class DbContextOptionsBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// Configures Entity Framework Core with SQL Server.
|
|
/// </summary>
|
|
public static DbContextOptionsBuilder UseElsaSqlServer(this DbContextOptionsBuilder builder, Assembly migrationsAssembly, string connectionString, ElsaDbContextOptions? options = null, Action<SqlServerDbContextOptionsBuilder>? configure = null) =>
|
|
builder
|
|
.UseElsaDbContextOptions(options)
|
|
.UseSqlServer(connectionString, db =>
|
|
{
|
|
db
|
|
.MigrationsAssembly(options.GetMigrationsAssemblyName(migrationsAssembly))
|
|
.MigrationsHistoryTable(options.GetMigrationsHistoryTableName(), options.GetSchemaName());
|
|
|
|
configure?.Invoke(db);
|
|
});
|
|
} |