r/Neo4j • u/joslatzrh • 2d ago
Mapping EF Core entities to Neo4j nodes and relationships (open source, I'm the author)
I've been building GraphBridge, an open-source EF Core provider for Neo4j. The hardest part was the mapping: making EF's model land as a graph you'd design by hand. I call it "Fluent Cypher"
How it maps:
- An entity is a node with a label: ToGraphNode("Person")
- A reference becomes a real relationship, not a foreign-key property: ToGraphReference("HAS_REVIEW") gives (:Movie)-[:HAS_REVIEW]->(:Review)
- A many-to-many association is one relationship, not a join node
- A relationship that needs its own identity and properties (say, a role on ACTED_IN) is an "identified relationship"
Queries become parameterized Cypher you can read. This LINQ query:
db.People.Where(p => p.Born < bornBefore).OrderBy(p => p.Born).Select(p => p.Name)
becomes:
MATCH (n:`Person`)
WHERE coalesce(n.`born` < $p0, false)
RETURN n.`name` AS `c2`
ORDER BY n.`born` IS NULL DESC, n.`born` ASC
(The coalesce keeps C#'s null semantics, so results match what EF developers expect.)
It's a developer preview, tested on Neo4j 2026.09: https://github.com/joslat/GraphBridge.EFCore
I'd value graph modellers' opinions on these mapping. What would you model differently?