diff --git a/src/ServiceStack.Authentication.MongoDB/MongoDBAuthRepository.cs b/src/ServiceStack.Authentication.MongoDB/MongoDBAuthRepository.cs index f146017..4b08fd5 100644 --- a/src/ServiceStack.Authentication.MongoDB/MongoDBAuthRepository.cs +++ b/src/ServiceStack.Authentication.MongoDB/MongoDBAuthRepository.cs @@ -52,14 +52,19 @@ private static string Counters_Col } } - public MongoDBAuthRepository(MongoDatabase mongoDatabase) + public MongoDBAuthRepository(MongoDatabase mongoDatabase, bool createMissingCollections) { this.mongoDatabase = mongoDatabase; + if (createMissingCollections) + { + CreateMissingCollections(); + } + if (!CollectionsExists()) { throw new InvalidOperationException("One of the collections needed by MongoDBAuthRepository is missing." + - "You can call CreateMissingCollections or DropAndReCreateCollections " + + "You can call MongoDBAuthRepository constructor with the parameter CreateMissingCollections set to 'true' " + "to create the needed collections."); } }