diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Extensions/ServicesExtensions.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Extensions/ServicesExtensions.cs
index 8c315cd9..dce5d8d4 100644
--- a/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Extensions/ServicesExtensions.cs
+++ b/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Extensions/ServicesExtensions.cs
@@ -3,7 +3,6 @@ using BootstrapAdmin.DataAccess.EFCore.Services;
using BootstrapAdmin.Web.Core;
using BootstrapBlazor.Components;
using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.DependencyInjection
{
@@ -16,17 +15,33 @@ namespace Microsoft.Extensions.DependencyInjection
///
///
///
+ ///
+ ///
///
- public static IServiceCollection AddEFCoreDataAccessServices(this IServiceCollection services)
+ public static IServiceCollection AddEFCoreDataAccessServices(this IServiceCollection services, Action optionConfigure, ServiceLifetime lifetime = ServiceLifetime.Singleton)
{
- services.AddDbContextFactory((provider, option) =>
- {
- //TODO: 后期改造成自定适配
- var configuration = provider.GetRequiredService();
- var connString = configuration.GetConnectionString("bb");
- option.UseSqlite(connString);
- });
+ services.AddDbContextFactory(optionConfigure, lifetime);
+ services.AddServices();
+ return services;
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddEFCoreDataAccessServices(this IServiceCollection services, Action optionConfigure, ServiceLifetime lifetime = ServiceLifetime.Singleton)
+ {
+ services.AddDbContextFactory(optionConfigure, lifetime);
+
+ services.AddServices();
+ return services;
+ }
+
+ private static IServiceCollection AddServices(this IServiceCollection services)
+ {
// 增加数据服务
services.AddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs
index 5e746615..ccebd83a 100644
--- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs
+++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServicesExtensions.cs
@@ -1,5 +1,6 @@
using BootstrapAdmin.Web.Services;
using System.Text;
+using Microsoft.EntityFrameworkCore;
namespace Microsoft.Extensions.DependencyInjection
{
@@ -67,12 +68,17 @@ namespace Microsoft.Extensions.DependencyInjection
// 增加 BootstrapApp 上下文服务
services.AddScoped();
+ // 增加 EFCore 数据服务
+ services.AddEFCoreDataAccessServices((provider, option) =>
+ {
+ var configuration = provider.GetRequiredService();
+ var connString = configuration.GetConnectionString("bb");
+ option.UseSqlite(connString);
+ });
+
// 增加 PetaPoco 数据服务
services.AddPetaPocoDataAccessServices();
- // 增加 EFCore 数据服务
- //services.AddEFCoreDataAccessServices();
-
return services;
}
}