From f2deb6ccd86a7313b627510e3bf1abe640f98726 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 30 Jul 2023 20:23:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E5=8F=91=E8=B7=9F=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserPointManagementDbContextFactory.cs | 2 +- src/UserPointManagement.Web/Program.cs | 11 ++++++++++- .../appsettings.Development.json | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs index 6edfa7e..9853b76 100644 --- a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs +++ b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs @@ -10,7 +10,7 @@ public class UserPointManagementDbContextFactory : IDesignTimeDbContextFactory(); optionsBuilder - .UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;") + .UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo_dev;") .UseSnakeCaseNamingConvention(); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); diff --git a/src/UserPointManagement.Web/Program.cs b/src/UserPointManagement.Web/Program.cs index 4851bec..9f39bce 100644 --- a/src/UserPointManagement.Web/Program.cs +++ b/src/UserPointManagement.Web/Program.cs @@ -5,9 +5,12 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using UserPointManagement.Persistence; namespace UserPointManagement.Web { @@ -15,7 +18,13 @@ namespace UserPointManagement.Web { public static void Main(string[] args) { - CreateHostBuilder(args).Build().Run(); + var host = CreateHostBuilder(args).Build(); + using (var serviceScope = host.Services.CreateScope()) + { + var context = serviceScope.ServiceProvider.GetRequiredService(); + context.Database.Migrate(); + } + host.Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => diff --git a/src/UserPointManagement.Web/appsettings.Development.json b/src/UserPointManagement.Web/appsettings.Development.json index d816066..253486c 100644 --- a/src/UserPointManagement.Web/appsettings.Development.json +++ b/src/UserPointManagement.Web/appsettings.Development.json @@ -4,7 +4,8 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.EntityFrameworkCore.Database": "Information" } }, "ProSettings": {