blob: 3f56b0c7b246c64bc8997d19ceea71ea88001354 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
using Microsoft.EntityFrameworkCore;
namespace LibraryAPI.Models {
public class LibraryContext : DbContext {
public DbSet<Author>? Authors { get; set; }
public DbSet<Book>? Books { get; set; }
public DbSet<UserAccount>? Users { get; set; }
public DbSet<Group>? Groups { get; set; }
public DbSet<GroupUserAccount>? GroupUserAccounts { get; set; }
public LibraryContext(DbContextOptions<LibraryContext> options) : base(options) {}
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<GroupUserAccount>().HasKey(sc => new { sc.UserAccountId, sc.GroupId });
}
}
}
|