2023-03-03 23:24:18 +03:30
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-01-25 20:38:47 +03:30
|
|
|
|
using MTWireGuard.Application.Models;
|
2023-06-02 15:26:29 +03:30
|
|
|
|
using MTWireGuard.Application.Models.Mikrotik;
|
2023-03-03 23:24:18 +03:30
|
|
|
|
|
2023-06-02 15:26:29 +03:30
|
|
|
|
namespace MTWireGuard.Application
|
2023-03-03 23:24:18 +03:30
|
|
|
|
{
|
|
|
|
|
public class DBContext : DbContext
|
|
|
|
|
{
|
|
|
|
|
public DbSet<WGPeerDBModel> Users { get; set; }
|
2024-01-25 20:38:47 +03:30
|
|
|
|
public DbSet<WGServerDBModel> Servers { get; set; }
|
|
|
|
|
public DbSet<DataUsage> DataUsages { get; set; }
|
|
|
|
|
public DbSet<LastKnownTraffic> LastKnownTraffic { get; set; }
|
2023-03-03 23:24:18 +03:30
|
|
|
|
|
|
|
|
|
public string DbPath { get; }
|
|
|
|
|
|
|
|
|
|
public DBContext()
|
|
|
|
|
{
|
|
|
|
|
DbPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "MikrotikWireguard.db");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
2024-01-25 20:38:47 +03:30
|
|
|
|
{
|
|
|
|
|
options.UseSqlite($"Data Source={DbPath}", opt =>
|
|
|
|
|
{
|
|
|
|
|
opt.MigrationsAssembly("MTWireGuard.Application");
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-03-03 23:24:18 +03:30
|
|
|
|
}
|
|
|
|
|
}
|