From 11b5cc83dcc4ba9d5981f78e242f257ac19b7ea3 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 8 Mar 2024 22:44:31 +0800 Subject: [PATCH] add db factory class into the module template. --- .../Repository/[Module]DbContextFactory.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]DbContextFactory.cs diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]DbContextFactory.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]DbContextFactory.cs new file mode 100644 index 000000000..d229c419e --- /dev/null +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Repository/[Module]DbContextFactory.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Oqtane.Infrastructure; + +namespace [Owner].Module.[Module].Repository +{ + public class [Module]DbContextFactory : IServerStartup + { + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + // not implemented + } + + public void ConfigureMvc(IMvcBuilder mvcBuilder) + { + // not implemented + } + + public void ConfigureServices(IServiceCollection services) + { + services.AddDbContextFactory<[Module]Context>(opt => { }, ServiceLifetime.Transient); + } + } +}