public static void ExecuteMigrations(this WebApplication app) { IServiceProvider serviceProvider = app.Services; MongoDbContext dbContext = (MongoDbContext)serviceProvider.GetRequiredService <IDbContext>(); Console.Write("Running database migrations..."); MongoDbMigrator.RunMigrations(dbContext); Console.WriteLine("done."); }
public void RunMigrations_ValidateIndexes() { MongoDbContext dbContext = CreateDbContext(); MongoDbMigrator.RunMigrations(dbContext); AssertIndexCount(2, dbContext.Database, DbSchema.UserContainer); AssertIndexExists(dbContext.Database, DbSchema.UserContainer, DbSchema.UserContainerIndexes.AuthId); AssertIndexCount(1, dbContext.Database, DbSchema.WorkspaceContainer); DeleteTestDatabase(dbContext); }
public void RunMigrations_ValidateTables() { MongoDbContext dbContext = CreateDbContext(); MongoDbMigrator.RunMigrations(dbContext); // validate tables List <string> collectionNames = dbContext.MongoClient.GetDatabase(DefaultTestDbName).ListCollectionNames().ToList(); Assert.AreEqual(2, collectionNames.Count); Assert.Contains(DbSchema.UserContainer, collectionNames); Assert.Contains(DbSchema.WorkspaceContainer, collectionNames); DeleteTestDatabase(dbContext); }