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 Lectures { get; set; } public DbSet LectureEvents { get; set; } public DbSet ScrapedLinks { get; set; } public DbSet 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}"); } }