Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using AnrixNetwork.Models;
- using AnrixReborn.Models;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore;
- using static AnrixReborn.Areas.Identity.Pages.Account.RegisterModel;
- namespace AnrixReborn.Data
- {
- public class ApplicationDbContext : IdentityDbContext<AnrixUser>
- {
- public DbSet<Dialog> Dialogs { get; set; }
- public DbSet<Message> Messages { get; set; }
- public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
- : base(options)
- {
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity<UserDialog>()
- .HasKey(bc => new { bc.UserId, bc.DialogId });
- modelBuilder.Entity<UserDialog>()
- .HasOne(bc => bc.User)
- .WithMany(b => b.UserDialogs)
- .HasForeignKey(bc => bc.UserId);
- modelBuilder.Entity<UserDialog>()
- .HasOne(bc => bc.Dialog)
- .WithMany(c => c.UserDialogs)
- .HasForeignKey(bc => bc.DialogId);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement