.NET Fiddle

CSharp · Console

/Program.cs

using System;
using Microsoft.EntityFrameworkCore;
using FileContextCore.Extensions;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.IO;

public class Program
{
	public static void Main()
	{
		Db db = new Db();
		
		db.DemoEntries.Add(new DemoEntry() {
			Content = "Das ist ein test"
		});
		
		db.SaveChanges();
		
		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 class DemoEntry
{
	[Key]
	public int Id { get; set; }
	
	public string Content { get; set; }
	
	public override string ToString() {
		return $"Id: {Id}; Content: {Content}";
	}
}
;