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.
45 lines
1.8 KiB
45 lines
1.8 KiB
using Entities;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace DbContextLib
|
|
{
|
|
public class UserDbContext : IdentityDbContext<IdentityUser>
|
|
{
|
|
public DbSet<UserEntity> Users { get; set; }
|
|
public DbSet<BlackListEntity> BlackLists { get; set; }
|
|
public DbSet<InquiryEntity> Inquiries { get; set; }
|
|
public DbSet<InquiryTableEntity> InquiryTables { get; set; }
|
|
public DbSet<LessonEntity> Lessons { get; set; }
|
|
public DbSet<ParagraphEntity> Paragraphs { get; set; }
|
|
public DbSet<SolutionEntity> Solutions { get; set; }
|
|
public DbSet<SuccessEntity> Successes { get; set; }
|
|
public DbSet<NotepadEntity> Notepads { get; set; }
|
|
|
|
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse");
|
|
}
|
|
|
|
base.OnConfiguring(optionsBuilder);
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
// Permet d'avoir les champs de la classe mère dans les classes filles et de ne pas avoir de table pour la classe mère
|
|
modelBuilder.Entity<ContentLessonEntity>().UseTpcMappingStrategy();
|
|
|
|
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.UserId);
|
|
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.InquiryId);
|
|
modelBuilder.Entity<InquiryEntity>().HasKey(s => s.Id);
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
}
|
|
} |