From 6b39d6e70687e4cb9a371771fbc5e03f8c666523 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 9 Mar 2021 11:16:47 +0800 Subject: [PATCH] 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. --- .../AbpDbContextConfigurationContext.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs index b9cf4e3ceb..09153937e3 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs @@ -32,7 +32,8 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection ExistingConnection = existingConnection; DbContextOptions = new DbContextOptionsBuilder() - .UseLoggerFactory(serviceProvider.GetRequiredService()); + .UseLoggerFactory(serviceProvider.GetRequiredService()) + .UseApplicationServiceProvider(serviceProvider); } } @@ -47,13 +48,14 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection [CanBeNull] string connectionStringName, [CanBeNull] DbConnection existingConnection) : base( - connectionString, - serviceProvider, - connectionStringName, + connectionString, + serviceProvider, + connectionStringName, existingConnection) { base.DbContextOptions = new DbContextOptionsBuilder() - .UseLoggerFactory(serviceProvider.GetRequiredService()); + .UseLoggerFactory(serviceProvider.GetRequiredService()) + .UseApplicationServiceProvider(serviceProvider);; } } -} \ No newline at end of file +}