diff --git a/Mongo.Migration/Migrations/Locators/MigrationLocator.cs b/Mongo.Migration/Migrations/Locators/MigrationLocator.cs index f5b5700..8895cd4 100644 --- a/Mongo.Migration/Migrations/Locators/MigrationLocator.cs +++ b/Mongo.Migration/Migrations/Locators/MigrationLocator.cs @@ -107,21 +107,7 @@ private static List GetAssemblies() private TMigrationType GetMigrationInstance(Type type) { - ConstructorInfo[] constructors = type.GetConstructors(); - - if (constructors.Length > 0) - { - var args = constructors - .First() - .GetParameters() - .Select(parameterInfo => _serviceProvider.GetRequiredService(parameterInfo.ParameterType)) - .ToArray(); - - return Activator.CreateInstance(type, args) as TMigrationType - ?? throw new InvalidOperationException($"Cannot create {type} migration"); - } - - return Activator.CreateInstance(type) as TMigrationType + return ActivatorUtilities.CreateInstance(_serviceProvider, type) as TMigrationType ?? throw new InvalidOperationException($"Cannot create {type} migration"); } } \ No newline at end of file