NFalkorDB extends StackExchange.Redis with a .NET-friendly API for working with the FalkorDB Redis module—bringing graph-native commands into your C# projects with ease.
Built on top of the native Execute and ExecuteAsync methods, NFalkorDB offers a set of extension methods that mirrors the command structure of Jedis's FalkorDB support, giving you familiar, fluent access to graph operations.
PM> Install-Package NFalkorDB -Version 1.0.0
Before using NFalkorDB, ensure the FalkorDB module is installed on your Redis server.
To verify:
MODULE LIST
Expected output (version may vary):
1) "name"
2) "graph"
3) "ver"
4) 4) (integer) 20811
NFalkorDB exposes FalkorDB commands as C# extension methods through StackExchange.Redis.
FalkorDB can be constructed either from an existing IDatabase or from a StackExchange.Redis configuration string.
// Using a configuration string / URL
var client = new FalkorDB("localhost:6379");
// Select a graph
Graph graph = client.SelectGraph("social");
// DB-level helpers
var graphs = client.ListGraphs(); // GRAPH.LIST
string timeout = client.GetConfig("TIMEOUT_MS"); // GRAPH.CONFIG GET TIMEOUT_MS
client.SetConfig("TIMEOUT_MS", 1000); // GRAPH.CONFIG SET TIMEOUT_MS 1000Async counterparts ListGraphsAsync, GetConfigAsync, and SetConfigAsync are also available.
The Graph class wraps core FalkorDB graph commands:
Query/QueryAsyncandReadOnlyQuery/ReadOnlyQueryAsyncwith optionaltimeoutin milliseconds.Copy/CopyAsyncforGRAPH.COPY.Delete/DeleteAsyncforGRAPH.DELETE.Explain/ExplainAsyncforGRAPH.EXPLAIN.Profile/ProfileAsyncforGRAPH.PROFILE.Slowlog,SlowlogAsync,SlowlogReset,SlowlogResetAsyncforGRAPH.SLOWLOG.
NFalkorDB provides helpers to create, drop, and list indices:
// Node indices
graph.CreateNodeRangeIndex("Person", "name");
graph.CreateNodeFulltextIndex("Person", "bio");
graph.CreateNodeVectorIndex("Person", dimension: 1536, similarityFunction: "euclidean", "embedding");
// Edge indices
graph.CreateEdgeRangeIndex("KNOWS", "since");
// Drop indices
graph.DropNodeRangeIndex("Person", "name");
// List indices (also ListIndicesAsync)
var indexResult = graph.ListIndices(); // CALL db.indexesConstraint APIs mirror FalkorDB GRAPH.CONSTRAINT support and auto-create required range indices for unique constraints:
// Node constraints
graph.CreateNodeUniqueConstraint("Person", "id");
graph.CreateNodeMandatoryConstraint("Person", "name");
// Edge constraints
graph.CreateEdgeUniqueConstraint("KNOWS", "since");
// Drop constraints
graph.DropNodeUniqueConstraint("Person", "id");
// List constraints (also ListConstraintsAsync)
var constraints = graph.ListConstraints(); // CALL DB.CONSTRAINTSNFalkorDB caches labels, relationship types, and property keys. If the server responds with a "version mismatch" error, the client:
- Throws
SchemaVersionMismatchExceptioninternally. - Refreshes the schema cache (
db.labels,db.propertyKeys,db.relationshipTypes). - Retries the query once transparently.
ResultSet now decodes additional scalar types returned by FalkorDB:
VALUE_DATETIME→DateTime(UTC) via Unix time in ms.VALUE_DATE→DateTime.Date.VALUE_TIME→TimeSpan(time since midnight in ms).VALUE_DURATION→TimeSpan(duration in ms).
Existing types (nodes, edges, paths, maps, arrays, points, vectors) remain supported.
Wherever synchronous helpers exist, async counterparts are being added. In particular:
- DB-level:
ListGraphsAsync,GetConfigAsync,SetConfigAsync. - Graph-level:
QueryAsync,ReadOnlyQueryAsync,CopyAsync,DeleteAsync,ExplainAsync,ProfileAsync,SlowlogAsync,SlowlogResetAsync. - Listing operations:
ListIndicesAsync,ListConstraintsAsync.
Use these in combination with await to integrate FalkorDB graph operations into async application flows.
// Connect the database and pick a Graph
ConnectionMultiplexer muxr = ConnectionMultiplexer.Connect(ConnectionString).
Graph graph = new FalkorDB(muxr.GetDatabase()).SelectGraph("social");
// Create the Graph
graph.Query("""CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
(:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
(:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})""");
// Query the Graph
ResultSet resultSet = graph.ReadOnlyQuery("MATCH (a:person)-[r:knows]->(b:person) RETURN a, r, b");For real-world usage and supported operations, see our integration tests:
These tests cover core functionality, including querying, creating, updating, and deleting graph data. Integration Tests
NFalkorDB is licensed under the Apache-2.0 license .
