DB update

This commit is contained in:
2026-03-06 06:27:03 +00:00
parent 33c341e3c6
commit e20ce70658
14 changed files with 1095 additions and 182 deletions

View File

@@ -1,9 +1,12 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Seasoned.Backend.Models;
namespace Seasoned.Backend.Data;
public class ApplicationDbContext : DbContext
// Inherit from IdentityDbContext to enable User management
public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { }
@@ -12,6 +15,15 @@ public class ApplicationDbContext : DbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Crucial: Call the base method so Identity tables are configured
base.OnModelCreating(modelBuilder);
modelBuilder.HasPostgresExtension("vector");
// Optional: Ensure the Recipe table links to the Identity User
modelBuilder.Entity<Recipe>()
.HasOne<IdentityUser>()
.WithMany()
.HasForeignKey(r => r.UserId);
}
}