Multiplying indices in RavenDB in asp.net MVC

In the RavenDB multi-user application (one database per tenant and one review database with shared tenant data), what will be the strategy for creating the index? (asp.net mvc)

In a simple (not mutant) application, you can create indexes in global.asax.

  • Theoretically, you can query each tenant and create indexes for each tenant in global.asax. But I think it will be a huge success when the number of tenants grows ...
  • Creating indexes when creating a tenant is not possible because existing tenants should be able to get new indexes when updating.

So, what would be the best practice regarding how and when to create these indexes?

+8
asp.net-mvc ravendb
source share
1 answer

You can use this method when starting the application without worrying about performance.

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 remember to include Raven.Client.Extensions

+10
source share

All Articles