From ebe4754f7cdfbe29fe87ebf962f9da076e2b84ae Mon Sep 17 00:00:00 2001 From: Michael <45694700+mac-michael@users.noreply.github.com> Date: Sat, 7 Dec 2024 20:33:23 +0100 Subject: [PATCH] Add option to disable automatic migrations during startup --- src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs | 3 ++- src/AspNetCore.Identity.Mongo/MongoIdentityOptions.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs b/src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs index 6b0d4db..4d348b2 100644 --- a/src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs +++ b/src/AspNetCore.Identity.Mongo/MongoIdentityExtensions.cs @@ -83,7 +83,8 @@ public static IdentityBuilder AddIdentityMongoDbProvider(thi var roleCollection = MongoUtil.FromConnectionString(dbOptions, dbOptions.RolesCollection); // apply migrations before identity services resolved - Migrator.Apply, TRole, TKey>(migrationCollection, migrationUserCollection, roleCollection); + if (!dbOptions.DisableAutoMigrations) + Migrator.Apply, TRole, TKey>(migrationCollection, migrationUserCollection, roleCollection); var builder = services.AddIdentity(setupIdentityAction ?? (x => { })); diff --git a/src/AspNetCore.Identity.Mongo/MongoIdentityOptions.cs b/src/AspNetCore.Identity.Mongo/MongoIdentityOptions.cs index 5467de7..2343e78 100644 --- a/src/AspNetCore.Identity.Mongo/MongoIdentityOptions.cs +++ b/src/AspNetCore.Identity.Mongo/MongoIdentityOptions.cs @@ -17,4 +17,6 @@ public class MongoIdentityOptions public SslSettings SslSettings { get; set; } public Action ClusterConfigurator { get; set; } + + public bool DisableAutoMigrations { get; set; } } \ No newline at end of file