mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using SharpbinV3.Data;
|
|
using SharpbinV3.Services;
|
|
|
|
namespace SharpbinV3
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
builder.Services.AddDbContext<AppDbContext>(opt =>
|
|
{
|
|
opt.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"));
|
|
});
|
|
builder.Services.AddScoped<IUserService, UserService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
|
db.Database.Migrate();
|
|
}
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|