- RavenDB 2.x Beginner's Guide
- Khaled Tannir
- 497字
- 2025-04-04 22:27:50
Time for action – creating a new database and adding sample data
Currently, the server is empty and we have an empty default database named system
. In order to see what the data will look like in the Document
database, we are going to use the Management Studio features to create a new database and create some sample data to populate the database with these data.
Note
We assume that the RavenDB server is running and the Management Studio is open in the web browser. If not, you can refer to the previous section to launch the RavenDB server in the Console mode.
- Click on your web browser to activate it. The RavenDB Management Studio is open.
Note
On the right side of the wizard form, you can choose to activate features provided by some available bundles (the RavenDB extensions). You can choose to activate data compression or data encryption and so on. These choices are inclusive and you can activate more than one bundle.
- Create a new database using the wizard form and name it
Sales
. - Click on the Tasks tab to display the tasks screen.
- Click on the Create Sample Data button to create the sample data.
- Click on the Documents tab to display the Documents screen and verify that the sample data has been added to the current database.
What just happened?
We just created a new database and populated it with sample data.
In steps 1 and 2, we created a new database named Sales
using the Management Studio's Create new database wizard.
By default, RavenDB allows anonymous access only for read requests (HTTP GET
), and since we are creating data, we need to specify a username
and a password
to generate the data. You can control this by changing the AnonymousAccess
setting in the server configuration file, which requires the server restart to apply changes.
In steps 3 and 4, we generated sample data using the Management Studio features.
When we create sample data using the Create Sample Data feature of the Management Studio, the current database must be empty and there shouldn't be any documents in the database, otherwise, the data generation action will fail.
While inserting the sample data into the Sales
database, the Management Studio displays the progress log. When the process is done, there are about 250 documents and four new indexes in the database.
In step 5, we opened the Documents screen and verified that the sample data has been added to the Sales
database.
Shutting down the RavenDB server in the Console mode
As easy it is to launch the RavenDB server in the Console mode, it is also easy to shutdown the RavenDB server in the Console mode.
Once the Start.cmd
file is executed, a new command prompt window is opened and it shows the server activity log. This RavenDB server instance would still be running until you press the q key command which will shutdown the RavenDB server and close the command prompt window.