@@ -4044,8 +4044,8 @@ public void Throws_when_wrong_DbContextOptions_used()
40444044 public void Throws_when_adding_two_contexts_using_non_generic_options ( )
40454045 {
40464046 var appServiceProvider = new ServiceCollection ( )
4047- . AddDbContext < NonGenericOptions1 > ( b => b . UseInMemoryDatabase ( Guid . NewGuid ( ) . ToString ( ) ) )
40484047 . AddDbContext < NonGenericOptions2 > ( b => b . UseInMemoryDatabase ( Guid . NewGuid ( ) . ToString ( ) ) )
4048+ . AddDbContext < NonGenericOptions1 > ( b => b . UseInMemoryDatabase ( Guid . NewGuid ( ) . ToString ( ) ) )
40494049 . BuildServiceProvider ( validateScopes : true ) ;
40504050
40514051 using var serviceScope = appServiceProvider
@@ -4078,26 +4078,31 @@ public NonGenericOptions2(DbContextOptions options)
40784078 }
40794079
40804080 [ ConditionalFact ]
4081- public void AddDbContext_adds_single_options_for_all_types ( )
4081+ public void AddDbContext_adds_options_for_all_types ( )
40824082 {
40834083 var services = new ServiceCollection ( )
40844084 . AddSingleton < DbContextOptions > ( _ => new DbContextOptions < NonGenericOptions1 > ( ) )
40854085 . AddDbContext < NonGenericOptions1 > ( optionsLifetime : ServiceLifetime . Singleton )
40864086 . AddDbContext < NonGenericOptions2 > ( optionsLifetime : ServiceLifetime . Singleton )
40874087 . BuildServiceProvider ( validateScopes : true ) ;
40884088
4089- Assert . Single ( services . GetServices < DbContextOptions > ( ) ) ;
4089+ Assert . Equal ( 3 , services . GetServices < DbContextOptions > ( ) . Count ( ) ) ;
4090+ Assert . Equal (
4091+ 2 , services . GetServices < DbContextOptions > ( )
4092+ . Select ( o => o . ContextType )
4093+ . Distinct ( )
4094+ . Count ( ) ) ;
40904095 }
40914096
40924097 [ ConditionalFact ]
4093- public void First_DbContextOptions_in_serviceCollection_selected ( )
4098+ public void Last_DbContextOptions_in_serviceCollection_selected ( )
40944099 {
40954100 var services = new ServiceCollection ( )
40964101 . AddDbContext < NonGenericOptions1 > ( optionsLifetime : ServiceLifetime . Singleton )
40974102 . AddDbContext < NonGenericOptions2 > ( optionsLifetime : ServiceLifetime . Singleton )
40984103 . BuildServiceProvider ( validateScopes : true ) ;
40994104
4100- Assert . Equal ( typeof ( NonGenericOptions1 ) , services . GetService < DbContextOptions > ( ) . ContextType ) ;
4105+ Assert . Equal ( typeof ( NonGenericOptions2 ) , services . GetService < DbContextOptions > ( ) . ContextType ) ;
41014106 }
41024107
41034108 [ ConditionalFact ]
0 commit comments