YPS-Beer/backend/YPS.Beer/Data/BeerContext.cs
2023-12-07 00:20:59 +00:00

22 lines
553 B
C#

using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using YPS.Beer.Models;
namespace YPS.Beer.Data;
public class BeerContext : IdentityDbContext<User>
{
public BeerContext(DbContextOptions<BeerContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<User>()
.HasMany(u => u.Favourites)
.WithOne(f => f.User)
.HasForeignKey("UserId");
base.OnModelCreating(builder);
}
}