The official C# SDK for Milvus.
The following table lists the recommended Milvus C# SDK version for each Milvus release line:
| Milvus version | Recommended SDK version |
|---|---|
| 2.2.x | v2.2.2 (V1) |
| 2.3.x | release/2.3 branch (V1) |
| 2.6.x | v2.6.0 (V2) |
Two generations of the SDK live in this repository:
| SDK | Assembly | Status |
|---|---|---|
V2 — Milvus.Client.V2 |
Milvus.Client.V2.dll |
Current; request/response DTO API aligned with the Java/C++/Rust V2 SDKs |
V1 — Milvus.Client |
Milvus.Client.dll |
Legacy, maintained for compatibility |
See CHANGELOG.md for release-specific features, fixes, and compatibility notes.
Supported .NET versions:
- .NET 8 (V2)
- .NET Core 2.1+ (V1)
- .NET Framework 4.6.1+ (V1)
New applications should use MilvusClientV2, which provides the current request/response-style API.
The legacy MilvusClient API is retained for compatibility with existing applications and is in
maintenance mode.
dotnet add package Milvus.Client.V2For the legacy V1 SDK:
dotnet add package Milvus.ClientThe following program connects to Milvus and then closes the connection:
using Milvus.Client.V2;
using Milvus.Client.V2.Types;
using var client = new MilvusClientV2(new ConnectConfig { Uri = "localhost:19530" });
await client.ConnectAsync();This program expects Milvus at localhost:19530. For an independently buildable project that covers
collection creation, insertion, loading, search, and cleanup, follow
Tutorial 1: Quickstart.
Standalone console projects are available under tutorial. They consume the
published Milvus.Client.V2 NuGet package as an application dependency (like an app that installs the
SDK from nuget.org) and provide a beginner-to-advanced sequence:
Each tutorial has its own prerequisites, configuration, run command, expected output, and
troubleshooting guidance. Start with the tutorial index for shared
connection settings and the recommended learning path.
Run one tutorial from the repository root with:
dotnet run --project tutorial/1_quickstartOn Linux, repository maintainers can start a disposable standalone Milvus server and run every tutorial with:
./scripts/run_tutorials.shAdditional V1 and V2 examples are available under examples. New applications should
start with the V2 examples in examples/v2. Each example is a small console program
that connects to a server, exercises one feature area, and cleans up after itself.
Run an example by its name:
dotnet run --project examples/v2 -- SimpleExampleExamples connect to Milvus and may create, modify, or delete resources. Review the selected example and its connection settings before running it.
Milvus.Client (V1) and Milvus.Client.V2 (V2) are delivered via the NuGet package manager.
| NuGet version | Branch | Description | Milvus version |
|---|---|---|---|
| v2.6.0 | 2.6 | V2 Milvus.Client.V2 first stable release |
2.6.x |
| v2.2.2 | main | Support grpc only | 2.2.x |
| v2.2.1 | main | Support restfulapi and grpc[Obsolete] | 2.2.x |
| v2.2.0 | 2.2 | Support grpc only[Obsolete] | 2.2.x |
connection refused: start Milvus or setMILVUS_URIto a reachable endpoint.unauthenticatedorpermission denied: setMILVUS_TOKENto a valid API key orusername:passwordcredential with permission for the requested operation.- load or index timeout: verify that Milvus is healthy and has enough CPU and memory, then retry.
- Docker or port errors from repository scripts: ensure
docker infosucceeds and the required ports are available.
The V2 client logs through Microsoft.Extensions.Logging. Provide a LoggerFactory on the
ConnectConfig to observe retry attempts and RPC failures:
using Microsoft.Extensions.Logging;
using Milvus.Client.V2;
using Milvus.Client.V2.Types;
var loggerFactory = LoggerFactory.Create(builder => builder
.AddSimpleConsole()
.SetMinimumLevel(LogLevel.Debug));
var config = new ConnectConfig
{
Uri = "localhost:19530",
LoggerFactory = loggerFactory
};(AddSimpleConsole requires the Microsoft.Extensions.Logging.Console package.)
The client logs health-check failures (Warning), the invocation and argument of each operation (Debug), and operation failures with their error code (Error). It never logs credentials, request payloads, filters, or vector data.
See DEVELOPMENT.md for development setup, builds, mock and server-backed tests, Docker automation, coverage, and protobuf regeneration.
You can find legacy V1 (Milvus.Client) Jupyter notebooks in the
docs/v1/notebooks folder.
- 00.Settings.ipynb
- 01.Connect to milvus.ipynb
- 02.Create a Collection.ipynb
- 03.Create a Partition.ipynb
- 04.Insert Vectors.ipynb
- 05.Build an Index on Vectors.ipynb
- 06.Search.ipynb
- 07.Query.ipynb
Requirements: C# notebooks require .NET 7 and the VS Code Polyglot extension.
