using Microsoft.EntityFrameworkCore; using System.Text.Json; namespace Webhook_4docs { public class WebhookDbContext(DbContextOptions options) : DbContext(options) { public DbSet ProcessedInvoices { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .Property(p => p.JsonBody) .HasColumnType("jsonb") .HasConversion( v => v == null ? null : v.RootElement.GetRawText(), v => v == null ? null : ParseJsonDocument(v)); } private static JsonDocument ParseJsonDocument(string json) => JsonDocument.Parse(json); } }