初始化
This commit is contained in:
44
看板定阅/Program.cs
Normal file
44
看板定阅/Program.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MySQLAccess.PGModels;
|
||||
using Npgsql.PostgresTypes;
|
||||
using 看板定阅.Services;
|
||||
|
||||
namespace 看板定阅
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
|
||||
//AddDbContext默认已经将DbContext注册为Scoped生命周期,再次显式注册会导致冲突
|
||||
builder.Services.AddDbContext<PostgresContext>(options =>
|
||||
{
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PGSqlStr"));
|
||||
});
|
||||
builder.Services.AddHostedService<MyTimer>();
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user