private static void RecreateDatabaseAndInstallObjects()
{
try
{
var client = new MongoClient(ConnectionUtils.GetConnectionString());
var database = client.GetDatabase(ConnectionUtils.GetDatabaseName());
var storageOptions = new MongoStorageOptions();
var names = MongoMigrationManager.RequiredSchemaVersion.CollectionNames(storageOptions.Prefix);
foreach (var name in names.Where(n => !n.EndsWith(".schema")))
{
var collection = database.GetCollection <BsonDocument>(name);
if (name.EndsWith(".signal"))
{
CleanSignalCollection(collection);
}
else
{
CleanCollection(collection);
}
}
}
catch (MongoException ex)
{
throw new InvalidOperationException("Unable to cleanup database.", ex);
}
}