---
title: "Client API: Setting up a Default Database"
url: "https://docs.ravendb.net/6.2/client-api/setting-up-default-database"
version: "6.2"
language: "csharp"
---

# Client API: Setting up a Default Database

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.java.md), [Node.js](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - A **default database** can be set in the Document Store.  
>   The default database is used when accessing the Document Store methods without explicitly specifying a database.
>
> - You can pass a different database when accessing the Document Store methods.  
>   This database will override the default database for that method action only.  
>   The default database value itself will Not change.
>
> - When accessing the Document Store methods, an exception will be thrown if a default database is Not set and if No other database was
>   explicitly passed.
>
> - In this page:
>   - [Example - Without a Default Database](#example---without-a-default-database)
>   - [Example - With a Default Database](#example---with-a-default-database)

## Example - Without a Default Database

```csharp
using (IDocumentStore store = new DocumentStore
{
  Urls = new[] { "http://your_RavenDB_server_URL" }
  // Default database is not set
}.Initialize())
{
  // Specify the 'Northwind' database when opening a Session
  using (IDocumentSession session = store.OpenSession(database: "NorthWind"))
  {
      // Session will operate on the 'Northwind' database
  }

  // Specify the 'Northwind' database when sending an Operation
  store.Maintenance.ForDatabase("Northwind").Send(new DeleteIndexOperation("NorthWindIndex"));
}
```

## Example - With a Default Database

The default database is defined in the Document Store's `Database` property.

```csharp
using (IDocumentStore store = new DocumentStore
{
  Urls = new[] { "http://your_RavenDB_server_URL" },
  // Default database is set to 'Northwind'
  Database = "Northwind"
}.Initialize())
{
  // Using the default database
  using (IDocumentSession northwindSession = store.OpenSession())
  {
      // Session will operate on the default 'Northwind' database
  }

  // Operation for default database
  store.Maintenance.Send(new DeleteIndexOperation("NorthWindIndex"));

  // Specify the 'AdventureWorks' database when opening a Session
  using (IDocumentSession adventureWorksSession = store.OpenSession(database: "AdventureWorks"))
  {
      // Session will operate on the specifed 'AdventureWorks' database
  }

  // Specify the 'AdventureWorks' database when sending an Operation
  store.Maintenance.ForDatabase("AdventureWorks").Send(new DeleteIndexOperation("AdventureWorksIndex"));
}
```

## See also

- [What is a Document Store](https://docs.ravendb.net/6.2/client-api/what-is-a-document-store.md)
- [Creating a Document Store](https://docs.ravendb.net/6.2/client-api/creating-document-store.md)
- [Setting up Authentication and Authorization](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.md)
- [Creating a Database](https://docs.ravendb.net/6.2/studio/database/create-new-database/general-flow.md)
