2023-07-24 02:24:32 +02:00
|
|
|
using System;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Threading.Tasks;
|
2020-11-17 13:46:23 +01:00
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
|
|
using BTCPayServer.Abstractions.Models;
|
2020-06-28 10:55:27 +02:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2021-01-06 15:51:13 +01:00
|
|
|
using Microsoft.Extensions.Options;
|
2024-04-25 10:27:45 +02:00
|
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
2020-11-17 13:46:23 +01:00
|
|
|
public class ApplicationDbContextFactory : BaseDbContextFactory<ApplicationDbContext>
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
2021-01-06 15:51:13 +01:00
|
|
|
public ApplicationDbContextFactory(IOptions<DatabaseOptions> options) : base(options, "")
|
2018-07-19 12:31:17 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-04-25 10:27:45 +02:00
|
|
|
public override ApplicationDbContext CreateContext(Action<NpgsqlDbContextOptionsBuilder> npgsqlOptionsAction = null)
|
2017-10-27 10:53:04 +02:00
|
|
|
{
|
|
|
|
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
2024-04-04 09:31:04 +02:00
|
|
|
builder.AddInterceptors(Data.InvoiceData.MigrationInterceptor.Instance);
|
2024-04-25 10:27:45 +02:00
|
|
|
ConfigureBuilder(builder, npgsqlOptionsAction);
|
2017-10-27 10:53:04 +02:00
|
|
|
return new ApplicationDbContext(builder.Options);
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
}
|