Skip to content

Commit 92c8bce

Browse files
mac-michaelvova3211
authored andcommitted
Add DisableAutoMigrations support to AddMongoDbStores
1 parent 350c9c4 commit 92c8bce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/AspNetCore.Identity.Mongo/MongoStoreExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ public static IdentityBuilder AddMongoDbStores<TUser, TRole, TKey>(this Identity
3636
var userCollection = MongoUtil.FromConnectionString<TUser>(dbOptions, dbOptions.UsersCollection);
3737
var roleCollection = MongoUtil.FromConnectionString<TRole>(dbOptions, dbOptions.RolesCollection);
3838

39-
Migrator.Apply<MigrationMongoUser<TKey>, TRole, TKey>(migrationCollection, migrationUserCollection,
40-
roleCollection);
39+
if (!dbOptions.DisableAutoMigrations)
40+
{
41+
Migrator.Apply<MigrationMongoUser<TKey>, TRole, TKey>(
42+
migrationCollection, migrationUserCollection, roleCollection);
43+
}
4144

4245
builder.Services.AddSingleton(x => userCollection);
4346
builder.Services.AddSingleton(x => roleCollection);

0 commit comments

Comments
 (0)