using Microsoft.EntityFrameworkCore; using TicketManager.Models; namespace TicketManager.Data { public class AppDbContext : DbContext { public AppDbContext(DbContextOptions options) : base(options) { } public DbSet Projects { get; set; } public DbSet Users { get; set; } public DbSet Tickets { get; set; } public DbSet Assignments { get; set; } public DbSet Edits { get; set; } public DbSet Notes { get; set; } public DbSet Files { get; set; } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity().HasKey(a => new { a.ProjectId, a.UserId }); builder.Entity().HasOne(a => a.Project).WithMany(p => p.Assignments).HasForeignKey(a => a.ProjectId); builder.Entity().HasOne(a => a.User).WithMany(u => u.Assignments).HasForeignKey(a => a.UserId); } } }