< Summary

Information
Class: Elsa.Persistence.EFCore.ElsaDbContextOptions
Assembly: Elsa.Persistence.EFCore.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/ElsaDbContextOptions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 52
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SchemaName()100%210%
get_MigrationsHistoryTableName()100%210%
get_MigrationsAssemblyName()100%210%
get_ProviderSpecificConfigurations()100%210%
ConfigureModel(...)100%210%
ConfigureModel(...)0%620%
GetModelConfigurations(...)100%210%
GetModelConfigurations(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/ElsaDbContextOptions.cs

#LineLine coverage
 1using JetBrains.Annotations;
 2using Microsoft.EntityFrameworkCore;
 3
 4namespace Elsa.Persistence.EFCore;
 5
 6/// <summary>
 7/// Provides options for configuring Elsa's Entity Framework Core integration.
 8/// </summary>
 9[PublicAPI]
 10public class ElsaDbContextOptions
 11{
 12    /// <summary>
 13    /// The schema used by Elsa.
 14    /// </summary>
 015    public string? SchemaName { get; set; }
 16
 17    /// <summary>
 18    /// The table used to store the migrations history.
 19    /// </summary>
 020    public string? MigrationsHistoryTableName { get; set; }
 21
 22    /// <summary>
 23    /// The assembly name containing the migrations.
 24    /// </summary>
 025    public string? MigrationsAssemblyName { get; set; }
 26
 027    public IDictionary<Type, Action<ModelBuilder>> ProviderSpecificConfigurations { get; set; } = new Dictionary<Type, A
 28
 29    public void ConfigureModel<TDbContext>(Action<ModelBuilder> configure) where TDbContext : DbContext
 30    {
 031        ConfigureModel(typeof(TDbContext), configure);
 032    }
 33
 34    public void ConfigureModel(Type dbContextType, Action<ModelBuilder> configure)
 35    {
 036        if (!ProviderSpecificConfigurations.TryGetValue(dbContextType, out var configurations))
 037            ProviderSpecificConfigurations[dbContextType] = configurations = _ => { };
 38
 039        configurations += configure;
 040        ProviderSpecificConfigurations[dbContextType] = configurations;
 041    }
 42
 43    public Action<ModelBuilder> GetModelConfigurations(DbContext dbContext)
 44    {
 045        return GetModelConfigurations(dbContext.GetType());
 46    }
 47
 48    public Action<ModelBuilder> GetModelConfigurations(Type dbContextType)
 49    {
 050        return ProviderSpecificConfigurations.TryGetValue(dbContextType, out var providerConfigurations) ? providerConfi
 51    }
 52}