From 6c53f3dc43f072dce4ffe4a1bd306074dd20ff39 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sun, 17 Aug 2025 22:10:27 +1000 Subject: Initial commit --- HyperBooruContext.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 HyperBooruContext.cs (limited to 'HyperBooruContext.cs') diff --git a/HyperBooruContext.cs b/HyperBooruContext.cs new file mode 100644 index 0000000..8223ee3 --- /dev/null +++ b/HyperBooruContext.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System.Text.Json; + +namespace HyperBooru; + +public class HyperBooruDbContext : DbContext { + public DbSet Objects { get; set; } + public DbSet TagDefinitions { get; set; } + public DbSet Tags { get; set; } + public DbSet Media { get; set; } + public DbSet 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}"); + } +} \ No newline at end of file -- cgit v1.3