You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.1 KiB
52 lines
2.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Entity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Contextlib
|
|
{
|
|
public class WTFContext : DbContext
|
|
{
|
|
//public DbSet<Admin> admins { get; set; }
|
|
public DbSet<Character> characters { get; set; }
|
|
public DbSet<Commentary> comments { get; set; }
|
|
public DbSet<DailyQuote> dailyquotes { get; set; }
|
|
//public DbSet<Favorite> favorites { get; set; }
|
|
public DbSet<Images> images { get; set; }
|
|
public DbSet<Question> question { get; set; }
|
|
public DbSet<Quiz> quizzes { get; set; }
|
|
//public DbSet<QuizQuestion> quizQuestions { get; set; }
|
|
public DbSet<Quote> quotes { get; set; }
|
|
//public DbSet<RecordQuiz> records { get; set; }
|
|
public DbSet<Source> sources { get; set; }
|
|
public DbSet<Users> users { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<Users>()
|
|
.HasMany(q => q.Favorite)
|
|
.WithMany(u => u.Favorite)
|
|
.UsingEntity<Favorite>(
|
|
l => l.HasOne<Quote>().WithMany().HasForeignKey(q => q.IdQuote),
|
|
r => r.HasOne<Users>().WithMany().HasForeignKey(u => u.IdUsers)
|
|
);
|
|
|
|
modelBuilder.Entity<Quiz>()
|
|
.HasMany(q => q.Questions)
|
|
.WithMany(u => u.Quizs)
|
|
.UsingEntity<QuizQuestion>(
|
|
l => l.HasOne<Question>().WithMany().HasForeignKey(q => q.IdQuestion),
|
|
r => r.HasOne<Quiz>().WithMany().HasForeignKey(u => u.IdQuiz)
|
|
);
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
=> options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WfDatabase.mdf;Trusted_Connection=True;");
|
|
}
|
|
}
|