Lectureplan/UWLib/LectureContext.cs
Robin Weichselbraun 03ddeba846 Performance update with HTMLAgilityPack
Added Branches
Added LinksToScrape
Added ScrapedLinks
2024-10-12 17:36:23 +02:00

46 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace UWLib
{
public class LectureContext : DbContext
{
public DbSet<Lecture> Lectures { get; set; }
public DbSet<LectureEvent> LectureEvents { get; set; }
public DbSet<ScrapedLink> ScrapedLinks { get; set; }
public DbSet<LinkToScrape> LinksToScrape { get; set; }
public string DbPath { get; }
public LectureContext(string path)
{
DbPath = path;
Database.Migrate();
}
public LectureContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "lecture.db");
DbPath = "lecture.db";
Database.Migrate();
}
// The following configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
}
}