You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Operations: How to Switch Operations to a Different Database

By default, the operations available directly in store are working on a default database that was setup for that store. To switch operations to a different database that is available on that server use the ForDatabase method.

Operations.ForDatabase

OperationExecutor ForDatabase(string databaseName);

Parameters
databaseName string Name of a database for which you want to get new Operations
Return Value
OperationExecutor New instance of Operations that is scoped to the requested database

Example

OperationExecutor operations = documentStore.Operations.ForDatabase("otherDatabase");

How to Switch Maintenance Operations to a Different Database

As with Operations, by default the Maintenance operations available directly in store are working on a default database that was setup for that store. To switch maintenance operations to a different database use the ForDatabase method.

Maintenance.ForDatabase

MaintenanceOperationExecutor ForDatabase(string databaseName);

Parameters
databaseName string Name of a database for which you want to get new Maintenance operations
Return Value
MaintenanceOperationExecutor New instance of Maintenance that is scoped to the requested database

Example

MaintenanceOperationExecutor maintenanceOperations = documentStore.Maintenance.ForDatabase("otherDatabase");