feat: 开发跟生产数据库分离
parent
0c2371be7e
commit
f2deb6ccd8
|
|
@ -10,7 +10,7 @@ public class UserPointManagementDbContextFactory : IDesignTimeDbContextFactory<U
|
||||||
{
|
{
|
||||||
var optionsBuilder = new DbContextOptionsBuilder<UserPointManagementDbContext>();
|
var optionsBuilder = new DbContextOptionsBuilder<UserPointManagementDbContext>();
|
||||||
optionsBuilder
|
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();
|
.UseSnakeCaseNamingConvention();
|
||||||
|
|
||||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using UserPointManagement.Persistence;
|
||||||
|
|
||||||
namespace UserPointManagement.Web
|
namespace UserPointManagement.Web
|
||||||
{
|
{
|
||||||
|
|
@ -15,7 +18,13 @@ namespace UserPointManagement.Web
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
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<UserPointManagementDbContext>();
|
||||||
|
context.Database.Migrate();
|
||||||
|
}
|
||||||
|
host.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information",
|
||||||
|
"Microsoft.EntityFrameworkCore.Database": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ProSettings": {
|
"ProSettings": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue