using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Pos.Dispatcher.Database.Model
{
    public partial class PosDispatcherContext
    {
        protected override void OnConfiguring(
            DbContextOptionsBuilder optionsBuilder)
        {
            LoadConfig l = new LoadConfig();
            IConfiguration config = l.ByEnvironment();
            string connectionString = config["MariaSqlServer"].ToString();
            optionsBuilder
                .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))
                .UseLoggerFactory(LoggerFactory.Create(b => b
                    .AddFilter(level => level >= LogLevel.Information)))
                .EnableSensitiveDataLogging()
                .EnableDetailedErrors();
            base.OnConfiguring(optionsBuilder);
        }
    }
}
