Building an Agentic System in .NET, Part 3: Durable Memory with Postgres and pgvector A developer has published the third part of a series on building an agentic system in .NET, showing how to add durable long-term memory using Postgres with the pgvector extension and EF Core. The approach stores distilled facts rather than raw conversation turns, scores each memory item for importance, and creates an HNSW index via raw migration DDL since EF Core lacks a fluent API for it. The writeup includes working entity definitions, package versions, and a recall query intended for production use. The previous two parts wired up the agent loop and gave it tools. The missing piece is memory. Session context resets with every new conversation, so anything the agent learned about a user, their preferences or an earlier decision is gone. Long term memory fixes that, but only if you store the right things, index them properly, and put them in front of the model at the right moment. This part covers all of it with working EF Core code, a real HNSW index, and a recall query you can put into production. The most common mistake is storing raw conversation turns. Transcripts grow without limit and are mostly noise: small talk, clarifications, the same question asked three ways. They belong in a separate session store with a time limit, and Redis with a TTL does that job well. Long term memory should hold distilled facts , things that last and are worth pulling back in a later session. Good candidates: Every item gets an importance score between 0.0 and 1.0 at write time, plus a timestamp. Both feed the ranking later. Packages first: dotnet add package Pgvector.EntityFrameworkCore --version 0.3.0 dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 10.0.3 Watch the version. Pgvector.EntityFrameworkCore v0.3.x targets EF Core 9 and 10. On EF Core 8, pin to v0.2.2. using Microsoft.EntityFrameworkCore; using Pgvector; public class MemoryItem { public Guid Id { get; set; } = Guid.NewGuid ; public string UserId { get; set; } = string.Empty; public string Content { get; set; } = string.Empty; public Vector Embedding { get; set; } = null ; public float Importance { get; set; } // 0.0 to 1.0 public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow; public DateTimeOffset LastAccessedAt { get; set; } = DateTimeOffset.UtcNow; } public class AgentDbContext DbContextOptions