forked from simplcommerce/SimplCommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
36 lines (31 loc) · 1.36 KB
/
Program.cs
File metadata and controls
36 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using SimplCommerce.Module.Core.Extensions;
namespace SimplCommerce.WebHost
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost2(args).Run();
}
// Changed to BuildWebHost2 to make EF don't pickup during design time
private static IWebHost BuildWebHost2(string[] args) =>
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration(SetupConfiguration)
.Build();
private static void SetupConfiguration(WebHostBuilderContext hostingContext, IConfigurationBuilder configBuilder)
{
var env = hostingContext.HostingEnvironment;
configBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
configBuilder.AddEnvironmentVariables();
var connectionStringConfig = configBuilder.Build();
configBuilder.AddEntityFrameworkConfig(options =>
options.UseNpgsql(connectionStringConfig.GetConnectionString("DefaultConnection"))
);
}
}
}