KEFCore is an Entity Framework Core provider that uses Apache Kafka as its back-end, storing each entity type in its own compacted topic. The author walks through the model, the context options and what actually lands in the topics.
Key points
- KafkaDbContext hides the provider wiring: BootstrapServers and DbName are mandatory, ApplicationId is optional.
- Topic names follow DbName.FullQualifiedDataClassName, so each entity type gets its own topic.
- Records are stored as JSON with a typeName field plus a positional data array that includes the key.
- Compacted topics keep only the latest value per key, which lets them behave like a primary key.
- The provider builds on KNet and Kafka Streams KTable semantics rather than a relational store.
- Startup and the first query are slow; UsePersistentStorage and skipping EnsureDeleted improve the experience.
Why it matters
Kafka as an EF Core back-end is not a drop-in replacement for SQL Server or PostgreSQL, and the article is honest that the provider is still in development with no migration path from an existing database. The realistic question is whether you already run a Kafka cluster and want EF Core-style access without adding another store beside it.
Before adopting, test what happens to records already in the topics when you rename a property or move a field. Measure cold start and first-query latency on your own cluster, and keep the broker as the source of truth only where non-.NET consumers can agree on the schema.
Real-world use
- A read-mostly reference data set that several services consume from the same Kafka topics.
- Using Kafka topics as a distributed cache that pushes changes to subscribed clients instead of Redis.
- Non-.NET consumers reading the same topics to reuse the data for other purposes.
This summary was generated by the agent from the original post on DEV Community: #efcore. The full text and all rights belong to its author and publisher. Go to original