Refactor ElsaDbContextBase to clean up schema setup
The schema setup in ElsaDbContextBase has been refactored for better readability and more efficient coding. The '_schema' private variable has been removed, and the 'Schema' property is now set directly within the constructor. This eliminates the need for extra code to handle the '_schema' variable, simplifying the overall approach. Additionally, minor formatting adjustments were made for better consistency in the code block.
This commit is contained in:
parent
ad236f626f
commit
f162186a5f
|
|
@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Elsa.EntityFrameworkCore.Common;
|
||||
|
||||
/// <summary>
|
||||
/// An optional base class to implement with some opinions on certain converters to install for certain DB providers.
|
||||
/// </summary>
|
||||
|
|
@ -13,9 +14,10 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
/// The default schema used by Elsa.
|
||||
/// </summary>
|
||||
public static string ElsaSchema { get; set; } = "Elsa";
|
||||
private string _schema;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Schema => _schema;
|
||||
public string Schema { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The table used to store the migrations history.
|
||||
/// </summary>
|
||||
|
|
@ -29,14 +31,9 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
|
|||
var elsaDbContextOptions = options.FindExtension<ElsaDbContextOptionsExtension>()?.Options;
|
||||
|
||||
// ReSharper disable once VirtualMemberCallInConstructor
|
||||
_schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;
|
||||
Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The schema used by Elsa.
|
||||
/// </summary>
|
||||
// protected virtual string Schema { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue