using Microsoft.EntityFrameworkCore; public class PostsDbContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var currentDir = System.IO.Directory.GetCurrentDirectory(); int showPostsIndex = currentDir.IndexOf("show-posts"); if (showPostsIndex > -1) { // Running from the bin directory, get the parent of "show-posts". currentDir = currentDir.Substring(0, showPostsIndex - 1); } string repoRoot = currentDir; optionsBuilder.UseSqlite($"Data Source={repoRoot}/service/service.db;Mode=ReadOnly;"); } public DbSet Posts { get; set; } }