Skip to content
Docs Try Aspire

RavenDBClientExtension Methods

Class Methods 4 members
Extension methods for connecting RavenDB database.
AddKeyedRavenDBClient(IHostApplicationBuilder, object, string, Action<RavenDBClientSettings>) Section titled AddKeyedRavenDBClient(IHostApplicationBuilder, object, string, Action<RavenDBClientSettings>) extension
Registers Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client, identified by a unique service key.
public static class RavenDBClientExtension
{
public static void AddKeyedRavenDBClient(
this IHostApplicationBuilder builder,
object serviceKey,
string connectionName,
Action<RavenDBClientSettings>? configureSettings = null)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services.
serviceKey object A unique key that identifies this instance of the RavenDB client service.
connectionName string The name used to retrieve the connection string from the "ConnectionStrings" configuration section.
configureSettings Action<RavenDBClientSettings> optional An optional delegate that can be used for customizing options. It is invoked after the settings are read from the configuration.
Notes:
  • Reads the configuration from "Aspire:RavenDB:Client" section.
  • The Documents.IDocumentStore is registered as a singleton, meaning a single instance is shared throughout the application's lifetime, while Session.IDocumentSession and Session.IAsyncDocumentSession are registered per request to ensure short-lived session instances for each use.
AddKeyedRavenDBClient(IHostApplicationBuilder, object, RavenDBClientSettings) Section titled AddKeyedRavenDBClient(IHostApplicationBuilder, object, RavenDBClientSettings) extension
Registers Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client, identified by a unique service key.
public static class RavenDBClientExtension
{
public static void AddKeyedRavenDBClient(
this IHostApplicationBuilder builder,
object serviceKey,
RavenDBClientSettings settings)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services.
serviceKey object A unique key that identifies this instance of the RavenDB client service.
settings RavenDBClientSettings The settings required to configure the Documents.IDocumentStore.
Notes:
  • If RavenDBClientSettings.DatabaseName is not specified and RavenDBClientSettings.CreateDatabase is set to 'false', Session.IDocumentSession and Session.IAsyncDocumentSession will not be registered.
  • The Documents.IDocumentStore is registered as a singleton, meaning a single instance is shared throughout the application's lifetime, while Session.IDocumentSession and Session.IAsyncDocumentSession are registered per request to ensure short-lived session instances for each use.
AddRavenDBClient(IHostApplicationBuilder, string, Action<RavenDBClientSettings>) Section titled AddRavenDBClient(IHostApplicationBuilder, string, Action<RavenDBClientSettings>) extension
Registers Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client.
public static class RavenDBClientExtension
{
public static void AddRavenDBClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<RavenDBClientSettings>? configureSettings = null)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services.
connectionName string The name used to retrieve the connection string from the "ConnectionStrings" configuration section.
configureSettings Action<RavenDBClientSettings> optional An optional delegate that can be used for customizing options. It is invoked after the settings are read from the configuration.
Notes:
  • Reads the configuration from "Aspire:RavenDB:Client" section.
  • The Documents.IDocumentStore is registered as a singleton, meaning a single instance is shared throughout the application's lifetime, while Session.IDocumentSession and Session.IAsyncDocumentSession are registered per request to ensure short-lived session instances for each use.
AddRavenDBClient(IHostApplicationBuilder, RavenDBClientSettings) Section titled AddRavenDBClient(IHostApplicationBuilder, RavenDBClientSettings) extension
Registers Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client.
public static class RavenDBClientExtension
{
public static void AddRavenDBClient(
this IHostApplicationBuilder builder,
RavenDBClientSettings settings)
{
// ...
}
}
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services.
settings RavenDBClientSettings The settings required to configure the Documents.IDocumentStore.
Notes:
  • If RavenDBClientSettings.DatabaseName is not specified and RavenDBClientSettings.CreateDatabase is set to 'false', Session.IDocumentSession and Session.IAsyncDocumentSession will not be registered.
  • The Documents.IDocumentStore is registered as a singleton, meaning a single instance is shared throughout the application's lifetime, while Session.IDocumentSession and Session.IAsyncDocumentSession are registered per request to ensure short-lived session instances for each use.