using Microsoft.EntityFrameworkCore;
using TakeoutSaaS.Infrastructure.Common.Persistence.DesignTime;
using TakeoutSaaS.Shared.Abstractions.Constants;
using TakeoutSaaS.Shared.Abstractions.Security;
using TakeoutSaaS.Shared.Abstractions.Tenancy;

namespace TakeoutSaaS.Infrastructure.Dictionary.Persistence;

/// <summary>
/// 设计时 DictionaryDbContext 工厂。
/// </summary>
internal sealed class DictionaryDesignTimeDbContextFactory
    : DesignTimeDbContextFactoryBase<DictionaryDbContext>
{
    /// <summary>
    /// 初始化字典库设计时上下文工厂。
    /// </summary>
    public DictionaryDesignTimeDbContextFactory()
        : base(DatabaseConstants.DictionaryDataSource, "TAKEOUTSAAS_DICTIONARY_CONNECTION")
    {
    }
    // 创建设计时上下文
    /// <summary>
    /// 创建设计时的 DictionaryDbContext。
    /// </summary>
    /// <param name="options">上下文配置。</param>
    /// <param name="tenantProvider">租户提供器。</param>
    /// <param name="currentUserAccessor">当前用户访问器。</param>
    /// <returns>DictionaryDbContext 实例。</returns>
    protected override DictionaryDbContext CreateContext(
        DbContextOptions<DictionaryDbContext> options,
        ITenantProvider tenantProvider,
        ICurrentUserAccessor currentUserAccessor)
        => new(options, tenantProvider, currentUserAccessor);
}
