Get started
About the official .NET driver
Neo4j provides official drivers for a number of popular programming languages. These drivers are supported by Neo4j.
Community drivers also exist for many languages, but vary greatly in terms of feature sets, maturity, and support. To find more about community drivers, visit https://neo4j.com/developer/language-guides/.
The following languages and frameworks are officially supported by Neo4j:
Language/framework | Versions supported |
---|---|
.NET |
.NET Standard 2.0. |
Go |
|
Java |
Java 17. |
JavaScript |
|
Python |
Python 3.7 and above. |
The driver API is intended to be topologically agnostic. This means that the underlying database topology — single instance, Causal Cluster, etc. — can be altered without requiring a corresponding alteration to application code.
In the general case, only the connection URI needs to be modified when changes are made to the topology.
The official drivers do not support HTTP communication. If you need an HTTP driver, choose one of the community drivers. See also the HTTP API documentation. |
Driver versions and installation
Wherever possible, it is recommended to use the latest stable driver release available. This will provide the greatest degree of stability and will ensure that the full set of server functionality is available. The drivers, when used with Neo4j Enterprise Edition, come with full cluster routing support. The drivers make no explicit distinction between Enterprise Edition and Community Edition however, and simply operate with the functionality made available by Neo4j itself.
The .NET driver is distributed via the NuGet Gallery. To find the latest version of the driver, visit https://www.nuget.org/packages/Neo4j.Driver/.
Dependencies
-
.NETStandard (^2.0)
-
System.Net.NameResolution (^4.3.0)
-
System.Net.Security (^4.3.2)
-
System.Net.Sockets (^4.3.0)
-
System.Runtime.InteropServices.RuntimeInformation (^4.3.0)
-
System.Runtime.Serialization.Primitives (^4.3.0)
-
System.Threading.Thread (^4.3.0)
-
System.ValueTuple (^4.5.0)
The .NET Reactive API is under package Neo4j.Driver.Reactive
.
It is built upon System.Reactive
.
There is no extra dependency required use .NET reactive API.
To install the latest version of the driver using NuGet in Visual Studio:
PM> Install-Package Neo4j.Driver
It is also an option to install a certain version of the driver.
PM> Install-Package Neo4j.Driver -Version $DOTNET_DRIVER_VERSION
The .Net driver uses asynchronous methods by default.
If you want to use blocking calls, the Neo4j.Driver.Simple
NuGet package contains a set of extensions.
This can be found at https://www.nuget.org/packages/Neo4j.Driver.Simple/.
The initial examples make use of these extensions.
In the following example we are installing driver version 5.26.
PM> Install-Package Neo4j.Driver -Version 5.26
The release notes for this driver are available here.
A "Hello World" example
The example below shows the minimal configuration necessary to interact with Neo4j through the .NET driver:
public class HelloWorldExample : IDisposable
{
private readonly IDriver _driver;
public HelloWorldExample(string uri, string user, string password)
{
_driver = GraphDatabase.Driver(uri, AuthTokens.Basic(user, password));
}
public void PrintGreeting(string message)
{
using var session = _driver.Session();
var greeting = session.ExecuteWrite(
tx =>
{
var result = tx.Run(
"CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
new { message });
return result.Single()[0].As<string>();
});
Console.WriteLine(greeting);
}
public void Dispose()
{
_driver?.Dispose();
}
public static void Main()
{
using var greeter = new HelloWorldExample("bolt://localhost:7687", "neo4j", "password");
greeter.PrintGreeting("hello, world");
}
}
Driver API docs
For a comprehensive listing of all driver functionality, please see the .NET API reference documentation.