summaryrefslogtreecommitdiff
path: root/HyperBooruContext.cs
blob: 8223ee303a38a95e8d0e239a6be24441310e7c44 (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
using Microsoft.EntityFrameworkCore;
using System.Text.Json;

namespace HyperBooru;

public class HyperBooruDbContext : DbContext {
    public DbSet<DbObject>        Objects        { get; set; }
    public DbSet<DbTagDefinition> TagDefinitions { get; set; }
    public DbSet<DbTag>           Tags           { get; set; }
    public DbSet<DbMedia>         Media          { get; set; }
    public DbSet<DbUploadedFile>  UploadedFiles  { get; set; }

    private IConfigService config;

    public HyperBooruDbContext(IConfigService config) =>
        this.config = config;

    protected override void OnConfiguring(DbContextOptionsBuilder options) {
        options.UseLazyLoadingProxies();

        var path = Path.Join(config.DataPath, "HyperBooru.db");
        options.UseSqlite($"Data Source = {config.DbPath}");
    }
}