Reputation: 1187
In a multitenant RavenDB application (one database per tenant, and one 'overview' database with general tenant data), what would be the index creation strategy? (asp.net mvc)
In a simple (not multitenant) application, you can create the indexes in global.asax.
So what would be the best practice as for how and when to create these indexes?
Upvotes: 8
Views: 691
Reputation: 6839
You can use this method on application startup, no worries about perf.
public static void CreateIndexesForDatabases(Assembly assemblyToScanForIndexingTasks, IDocumentStore documentStore, string[] databases)
{
var catalog = new CompositionContainer(new AssemblyCatalog(assemblyToScanForIndexingTasks));
foreach (var database in databases)
{
IndexCreation.CreateIndexes(catalog, documentStore.DatabaseCommands.ForDatabase(database), documentStore.Conventions);
}
}
just don't forget to include Raven.Client.Extensions
Upvotes: 10