Initial commit
This commit is contained in:
22
backend/YPS.Beer/Data/BeerContext.cs
Normal file
22
backend/YPS.Beer/Data/BeerContext.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user