CommunityToolkit.Aspire.SurrealDb 9.8.0-beta.388

Prefix Reserved
This is a prerelease version of CommunityToolkit.Aspire.SurrealDb.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CommunityToolkit.Aspire.SurrealDb --version 9.8.0-beta.388
                    
NuGet\Install-Package CommunityToolkit.Aspire.SurrealDb -Version 9.8.0-beta.388
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" Version="9.8.0-beta.388" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommunityToolkit.Aspire.SurrealDb" Version="9.8.0-beta.388" />
                    
Directory.Packages.props
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CommunityToolkit.Aspire.SurrealDb --version 9.8.0-beta.388
                    
#r "nuget: CommunityToolkit.Aspire.SurrealDb, 9.8.0-beta.388"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CommunityToolkit.Aspire.SurrealDb@9.8.0-beta.388
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=9.8.0-beta.388&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=9.8.0-beta.388&prerelease
                    
Install as a Cake Tool

CommunityToolkit.Aspire.SurrealDb

Registers a SurrealDbClient in the DI container for connecting to a SurrealDB instance.

Getting started

Prerequisites

  • SurrealDB cluster.

Install the package

Install the .NET Aspire SurrealDB Client library with NuGet:

dotnet add package CommunityToolkit.Aspire.SurrealDb

Usage example

In the Program.cs file of your project, call the AddSurrealClient extension method to register a SurrealDbClient for use via the dependency injection container. The method takes a connection name parameter.

builder.AddSurrealClient("surreal");

Configuration

The .NET Aspire SurrealDB Client integration provides multiple options to configure the server connection based on the requirements and conventions of your project.

Use a connection string

When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string when calling builder.AddSurrealClient():

builder.AddSurrealClient("surreal");

And then the connection string will be retrieved from the ConnectionStrings configuration section:

{
    "ConnectionStrings": {
        "surreal": "Server=ws://127.0.0.1:8000/rpc;Namespace=test;Database=test;Username=root;Password=root"
    }
}

Use configuration providers

The .NET Aspire SurrealDB Client integration supports Microsoft.Extensions.Configuration. It loads the SurrealDbClientSettings from configuration by using the Aspire:Surreal:Client key. Example appsettings.json that configures some of the options:

{
  "Aspire": {
    "Surreal": {
      "Client": {
        "Options": {
          "Endpoint": "ws://127.0.0.1:8000/rpc", 
          "Namespace": "test",
          "Database": "test",
          "Username": "root",
          "Password": "root"
        }
      }
    }
  }
}

Use inline delegates

Also you can pass the Action<SurrealDbClientSettings> configureSettings delegate to set up some or all the options inline, for example to set the API key from code:

builder.AddSurrealDbClient("surreal", settings => settings.Options.Endpoint = "ws://localhost:8000/rpc");

AppHost extensions

In your AppHost project, install the CommunityToolkit.Aspire.Hosting.SurrealDb library with NuGet:

dotnet add package CommunityToolkit.Aspire.Hosting.SurrealDb

Then, in the Program.cs file of AppHost, register a SurrealDB cluster and consume the connection using the following methods:

var db = builder.AddSurrealServer("surreal")
                .AddNamespace("ns")
                .AddDatabase("db");

var myService = builder.AddProject<Projects.MyService>()
                       .WithReference(db);

The WithReference method configures a connection in the MyService project named db. In the Program.cs file of MyService, the SurrealDB connection can be consumed using:

builder.AddSurrealClient("db");

Then, in your service, inject SurrealDbClient and use it to interact with the SurrealDB instance:

public class MyService(SurrealDbClient client)
{
    // ...
}

Additional documentation

Feedback & contributing

https://github.com/CommunityToolkit/Aspire

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.8.0-beta.389 124 9/18/2025
9.8.0-beta.388 137 9/16/2025
9.8.0-beta.386 146 9/15/2025
9.8.0-beta.385 141 9/15/2025
9.8.0-beta.384 39 9/13/2025
9.8.0-beta.376 119 9/8/2025
9.8.0-beta.375 50 9/6/2025
9.8.0-beta.373 131 9/5/2025
9.8.0-beta.372 126 9/4/2025
9.8.0-beta.370 117 9/2/2025
9.8.0-beta.364 115 9/1/2025
9.7.2 174 8/29/2025
9.7.2-beta.362 163 8/29/2025
9.7.2-beta.361 166 8/29/2025
9.7.2-beta.360 162 8/29/2025
9.7.2-beta.359 164 8/28/2025
9.7.2-beta.358 159 8/28/2025
9.7.2-beta.357 164 8/28/2025
9.7.1 182 8/27/2025
9.7.1-beta.355 163 8/27/2025
9.7.1-beta.354 160 8/27/2025
9.7.1-beta.353 164 8/27/2025
9.7.1-beta.352 161 8/27/2025
9.7.1-beta.351 169 8/27/2025
9.7.1-beta.348 121 8/14/2025
9.7.1-beta.344 69 8/10/2025
9.7.1-beta.343 195 8/8/2025
9.7.1-beta.342 203 8/7/2025
9.7.1-beta.341 202 8/6/2025
9.7.1-beta.340 187 8/5/2025
9.7.1-beta.339 184 8/5/2025
9.7.0 92 8/1/2025
9.7.0-beta.337 82 8/1/2025
9.7.0-beta.336 96 8/1/2025
9.7.0-beta.335 98 8/1/2025