Add EF Core, Npgsql, Todo entity, and AppDbContext

This commit is contained in:
EugeneTes
2026-08-15 11:29:39 +00:00
parent f7b0b7fb59
commit 1e2a60880e
4 changed files with 60 additions and 21 deletions

View File

@@ -1,21 +1,23 @@
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();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseAuthorization();
app.MapControllers();
app.Run();
using Backend.Data;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("Postgres")));
// MARKER: CORS SERVICES
// MARKER: AUTH SERVICES
builder.Services.AddControllers();
var app = builder.Build();
// MARKER: CORS MIDDLEWARE
// MARKER: AUTH MIDDLEWARE
app.MapControllers();
app.Run();