Abhay Naik
Abhay Naik

Reputation: 420

Ravendb 4 - Create Index Programmatically

How to add a index to specific database in RavenDb 4. I see the function

new SearchableIndex().Execute(_documentStore);

How to specify the database, without setting the default database as part of document store initialization. I wish to pass the database name as parameter.

Upvotes: 1

Views: 105

Answers (1)

Andrej Krivulčík
Andrej Krivulčík

Reputation: 387

You set the database for the DocumentStore using the Database property. When initializing, do it like this:

var _documentStore = new DocumentStore
{
    Urls = new[] { "http://localhost:8080" },
    Database = "databaseName"
};

new SearchableIndex().Execute(_documentStore);

Upvotes: 1

Related Questions