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": {