Browse Source

Use application service provider in AbpDbContextConfigurationContext

https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontextoptionsbuilder.useapplicationserviceprovider?view=efcore-5.0
This is done automatically when using 'AddDbContext' or 'AddDbContextPool', so it is rare that this method needs to be called.
pull/7996/head
maliming 6 years ago
parent
commit
6b39d6e706
  1. 14
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs

14
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs

@ -32,7 +32,8 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection
ExistingConnection = existingConnection; ExistingConnection = existingConnection;
DbContextOptions = new DbContextOptionsBuilder() DbContextOptions = new DbContextOptionsBuilder()
.UseLoggerFactory(serviceProvider.GetRequiredService<ILoggerFactory>()); .UseLoggerFactory(serviceProvider.GetRequiredService<ILoggerFactory>())
.UseApplicationServiceProvider(serviceProvider);
} }
} }
@ -47,13 +48,14 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection
[CanBeNull] string connectionStringName, [CanBeNull] string connectionStringName,
[CanBeNull] DbConnection existingConnection) [CanBeNull] DbConnection existingConnection)
: base( : base(
connectionString, connectionString,
serviceProvider, serviceProvider,
connectionStringName, connectionStringName,
existingConnection) existingConnection)
{ {
base.DbContextOptions = new DbContextOptionsBuilder<TDbContext>() base.DbContextOptions = new DbContextOptionsBuilder<TDbContext>()
.UseLoggerFactory(serviceProvider.GetRequiredService<ILoggerFactory>()); .UseLoggerFactory(serviceProvider.GetRequiredService<ILoggerFactory>())
.UseApplicationServiceProvider(serviceProvider);;
} }
} }
} }

Loading…
Cancel
Save