You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: How to switch command to a different database?

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


IDatabaseCommands ForDatabase(string database);
database string name of a database for which you want to get new commands
Return Value
IDatabaseCommands New instance of commands that is scoped to the requested database.


IDatabaseCommands commands = store.DatabaseCommands.ForDatabase("otherDatabase");


IDatabaseCommands ForSystemDatabase();
Return Value
IDatabaseCommands Method returns new instance of commands that is scoped to the system database.


IDatabaseCommands systemCommands = store.DatabaseCommands.ForSystemDatabase();