< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.Infrastructure.Core.BaseDbContext<T>
Assembly: ZhEaIsNsAaBn.Infrastructure.Core
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Core/DbContexts/BaseDbContext.cs
Line coverage
64%
Covered lines: 9
Uncovered lines: 5
Coverable lines: 14
Total lines: 65
Line coverage: 64.2%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
.ctor(...)100%11100%
CustomConfiguration(...)100%210%
ConfigureEnumsProperties(...)100%11100%
ConfigureUlongProperties(...)100%11100%
OnModelCreating(...)100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Core/DbContexts/BaseDbContext.cs

#LineLine coverage
 1using System.Reflection;
 2
 3namespace ZhEaIsNsAaBn.Infrastructure.Core;
 4
 5/// <summary>
 6/// Base <see cref="DbContext"/> with the shared model conventions: required <c>CreatedDate</c>, decimals with precision
 7/// scale 2, restrict-delete foreign keys, <c>PhoneNumber</c> converters, and every <see cref="IEntityTypeConfiguration{
 8/// the configuration assembly. Database defaults (<c>CreatedDate</c>, sequential Guid keys) come from the provider pack
 9/// <c>UseSqlServerInfrastructure()</c> (<c>getdate()</c>, <c>NEWSEQUENTIALID()</c>). Audit fields (<c>UpdatedDate</c> i
 10/// only by <see cref="AuditInterceptor{TId}"/> (<c>WithAuditing&lt;TId&gt;()</c>).
 11/// </summary>
 12/// <remarks>
 13/// <c>OnModelCreating</c> is sealed. Put model configuration in <see cref="CustomConfiguration"/>.
 14/// </remarks>
 15/// <typeparam name="TAppDbContext">The application's context type (for typed <see cref="DbContextOptions{TContext}"/>).
 16public abstract class BaseDbContext< TAppDbContext > : DbContext
 17    where TAppDbContext : DbContext
 18{
 19    private readonly Assembly _configurationAssembly;
 20
 21
 22    /// <summary>Creates the context; configure the provider in <c>OnConfiguring</c>.</summary>
 23    /// <param name="configurationAssembly">The assembly whose <see cref="IEntityTypeConfiguration{TEntity}"/> classes a
 24    /// <exception cref="ArgumentNullException"><paramref name="configurationAssembly"/> is <see langword="null"/>.</exc
 025    protected BaseDbContext( Assembly configurationAssembly )
 26    {
 027        ArgumentNullException.ThrowIfNull( configurationAssembly );
 28
 029        _configurationAssembly = configurationAssembly;
 030    }
 31
 32    /// <summary>Creates the context with options from DI.</summary>
 33    /// <param name="options">The context options.</param>
 34    /// <param name="configurationAssembly">The assembly whose <see cref="IEntityTypeConfiguration{TEntity}"/> classes a
 35    /// <exception cref="ArgumentNullException"><paramref name="configurationAssembly"/> is <see langword="null"/>.</exc
 65236    protected BaseDbContext( DbContextOptions<TAppDbContext> options, Assembly configurationAssembly ) : base( options )
 37    {
 65238        ArgumentNullException.ThrowIfNull( configurationAssembly );
 39
 65240        _configurationAssembly = configurationAssembly;
 65241    }
 42
 43
 44    /// <summary>Override to configure the model. Runs after the shared conventions and before the assembly configuratio
 45    /// <param name="modelBuilder">The model builder.</param>
 046    public virtual void CustomConfiguration( ModelBuilder modelBuilder ) { }
 47
 48    /// <summary>Stores every enum property by name as Unicode text of 50 (<c>nvarchar(50)</c> on SQL Server). Call it f
 49    /// <param name="modelBuilder">The model builder.</param>
 1650    protected virtual void ConfigureEnumsProperties( ModelBuilder modelBuilder ) => BaseDbContextConfiguration.Configure
 51
 52    /// <summary>Stores every <see cref="ulong"/> property as Unicode text of 20 (<c>nvarchar(20)</c> on SQL Server). Ca
 53    /// <param name="modelBuilder">The model builder.</param>
 1654    protected virtual void ConfigureUlongProperties( ModelBuilder modelBuilder ) => BaseDbContextConfiguration.Configure
 55
 56    /// <summary>Applies the shared conventions, <see cref="CustomConfiguration"/> and the assembly configurations.</sum
 57    /// <param name="modelBuilder">The model builder.</param>
 58    protected sealed override void OnModelCreating( ModelBuilder modelBuilder )
 59    {
 4460        BaseDbContextConfiguration.OnModelCreating( modelBuilder, CustomConfiguration, _configurationAssembly, this.GetM
 61
 62
 4463        base.OnModelCreating( modelBuilder );
 4464    }
 65}