using Microsoft.EntityFrameworkCore;
using FileContextCore.Extensions;
using System.ComponentModel.DataAnnotations;
public static void Main()
db.DemoEntries.Add(new DemoEntry() {
Content = "Das ist ein test"
db.DemoEntries.ToList().ForEach(entry => Console.WriteLine(entry));
Console.WriteLine("\nContent of .json file");
Console.WriteLine(File.ReadAllText(AppContext.BaseDirectory + "DemoEntry.json"));
public class Db : DbContext
public DbSet<DemoEntry> DemoEntries { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
optionsBuilder.UseFileContext(serializer: "json", location: AppContext.BaseDirectory);
public int Id { get; set; }
public string Content { get; set; }
public override string ToString() {
return $"Id: {Id}; Content: {Content}";