mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
* More Options refactoring Continues refactoring config classes to use the propert Options pattern where possible. DataDirectories and DatabaseOptions are now configured the Options pattern and the BTCPayOptions is now moved alongside the other config setup * Move COnfigure logic for Options to the Startup
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.Reflection;
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
using BTCPayServer.Abstractions.Models;
|
|
using BTCPayServer.Plugins.Test.Migrations;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Design;
|
|
|
|
namespace BTCPayServer.Plugins.Test
|
|
{
|
|
|
|
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<TestPluginDbContext>
|
|
{
|
|
public TestPluginDbContext CreateDbContext(string[] args)
|
|
{
|
|
|
|
var builder = new DbContextOptionsBuilder<TestPluginDbContext>();
|
|
|
|
builder.UseSqlite("Data Source=temp.db");
|
|
|
|
return new TestPluginDbContext(builder.Options, true);
|
|
}
|
|
}
|
|
|
|
public class TestPluginDbContextFactory : BaseDbContextFactory<TestPluginDbContext>
|
|
{
|
|
public TestPluginDbContextFactory(IOptions<DatabaseOptions> options) : base(options, "BTCPayServer.Plugins.Test")
|
|
{
|
|
}
|
|
|
|
public override TestPluginDbContext CreateContext()
|
|
{
|
|
var builder = new DbContextOptionsBuilder<TestPluginDbContext>();
|
|
ConfigureBuilder(builder);
|
|
return new TestPluginDbContext(builder.Options);
|
|
|
|
}
|
|
}
|
|
}
|