blob: 551ca5d4c6d8ca507577c3287beaa43c5b25c204 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore;
using Classes;
namespace Database {
public class DatabaseContext : DbContext {
public DatabaseContext() {
Details = Task.Run(async () => await DetailsHelper.GetDetails()).GetAwaiter().GetResult();
}
public DbSet<Article> Articles;
public DbSet<Config> Configs;
public Dictionary<string, string> Details;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseMySQL($"server=localhost;port=3306;user={Details["username"]};password={Details["password"]};database={Details["database"]}");
}
}
}
|