Skip to content

Unable to resolve service for type 'FluentMigrator.Runner.Processors.ProcessorOptions' #1884

Description

@Cynicszm

Describe the bug
Hopefully something I'm doing wrong or missing when upgrading. Please can you assist.

Upgraded FluentMigrator from version 5.2.0 to version 6.0.

Previous AddFluentMigratorCore configuration no longer works and throws an invalid operation exception.

 ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: FluentMigrator.Runner.MigrationScopeHandler Lifetime: Scoped ImplementationType: FluentMigrator.Runner.MigrationScopeHandler': Unable to resolve service for type 'FluentMigrator.Runner.Processors.ProcessorOptions' while attempting to activate 'FluentMigrator.Runner.MigrationScopeHandler'.
 ---> System.InvalidOperationException: Unable to resolve service for type 'FluentMigrator.Runner.Processors.ProcessorOptions' while attempting to activate 'FluentMigrator.Runner.MigrationScopeHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
   at Microsoft.Extensions.Hosting.HostApplicationBuilder.Build()
   at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
   at Program.<Main>$(String[] args)

To Reproduce
Use the IWebHostBuilder configuration below

 builder.ConfigureServices( ( _, services ) =>
     {
		//Configure FluentMigrator
		services.AddFluentMigratorCore()
			.ConfigureRunner( rb => rb.AddSqlServer() )
			.AddLogging( x => x.AddSerilog() )
			.Configure<FluentMigratorLoggerOptions>( cfg =>
			{
				cfg.ShowSql = true;
				cfg.ShowElapsedTime = true;
			} )
			.BuildServiceProvider();

		//Configure FluentMigrator ConnectionStringReader
		services
			.AddSingleton<RepositoryConnectionStringReader>()
			.AddScoped<IConnectionStringReader>(
				sp => sp.GetRequiredService<RepositoryConnectionStringReader>() )
			.BuildServiceProvider( true );
	});

Expected behavior
The configuration to work and build.

Information (please complete the following information):

  • OS: Windows 11
  • Platform: .NET 8
  • FluentMigrator version 6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions