neo4j-driver-dotnet-skill

Guides C# and .NET applications connecting to Neo4j using the official Neo4j.Driver v6 API.

Updated Aug 25, 2026
One-click install
npx skills add https://github.com/cardox6/steuer-graph --skill neo4j-driver-dotnet-skill-cardox6
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: neo4j-driver-dotnet-skill
Source: https://github.com/cardox6/steuer-graph/tree/main/.agents/skills/neo4j-driver-dotnet-skill
Command: npx skills add https://github.com/cardox6/steuer-graph --skill neo4j-driver-dotnet-skill-cardox6

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Neo4j.Driver, and includes references (resource) components.

What problem does it solve? Writing correct Neo4j client code in .NET involves many subtle traps: disposing drivers synchronously, misusing DI lifetimes, returning cursors from managed transactions, or mishandling null graph values. This Skill provides authoritative patterns and a mistake/fix reference for the official Neo4j .NET Driver v6 so C# code connects, queries, and handles errors correctly the first time. ## Core Features & Use Cases - Driver lifecycle and DI setup: Register IDriver as a singleton in ASP.NET Core, use await using, verify connectivity at startup, and load credentials from configuration. - API selection guidance: Decision table for ExecutableQuery vs managed transactions (ExecuteReadAsync/ExecuteWriteAsync) vs explicit transactions, with cursor consumption rules. - Type mapping and batching: Cypher-to-.NET type tables, null-safe record access, UNWIND batching with anonymous types, and Preview object mapping to C# records. - Use Case: You are building an ASP.NET Core service backed by Neo4j Aura. Use this Skill to wire up the driver in Program.cs, run parameterized queries with ExecutableQuery, stream large results via ExecuteReadAsync, and avoid the 20+ documented common mistakes. ## Quick Start Ask the assistant to show how to register the Neo4j driver as a singleton in ASP.NET Core and run a parameterized query with ExecutableQuery.

Frequently Asked Questions about neo4j-driver-dotnet-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect to Neo4j from C# or .NET?▼

Install the Neo4j.Driver NuGet package, create one IDriver instance with GraphDatabase.Driver using a neo4j+s:// or bolt:// URI and AuthTokens, then call VerifyConnectivityAsync. Use await using since IDriver implements IAsyncDisposable.

How do I register the Neo4j driver in ASP.NET Core dependency injection?▼

Register IDriver as a singleton in Program.cs with AddSingleton, never Scoped or Transient, and add a shutdown hosted service to dispose it. Never register IAsyncSession in DI; open sessions per unit of work instead.

What is the difference between ExecutableQuery and ExecuteReadAsync in the Neo4j .NET driver?▼

ExecutableQuery is the eager, auto-retrying default for simple queries and manages sessions and bookmarks automatically. ExecuteReadAsync and ExecuteWriteAsync stream large results lazily and support multiple queries per transaction, but the cursor must be consumed inside the callback.

Why does my Neo4j cursor throw after a managed transaction returns?▼

Returning an IResultCursor from an ExecuteReadAsync or ExecuteWriteAsync callback closes the transaction, invalidating the cursor. Consume it inside the callback with ToListAsync or a FetchAsync loop before returning.

Does the Neo4j .NET driver support mapping query results to C# records?▼

Yes, via the Preview mapping API. Add using Neo4j.Driver.Preview.Mapping, then call AsObject<T> on a record or AsObjectsAsync<T> for bulk mapping; RETURN key names map to C# record properties by name.

When should I not use this Neo4j .NET driver guidance?▼

It does not cover writing or optimizing Cypher queries, which belongs to a Cypher authoring skill, nor driver version upgrades, which belong to a migration skill. It targets driver v6 on .NET 8, 9, and 10 only.