using Entities.SQLudeoDB; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Cryptography.KeyDerivation; using Microsoft.EntityFrameworkCore; using System.Security.Cryptography; using Microsoft.AspNetCore.Identity; namespace DbContextLib { public class UserDbContext : IdentityDbContext { public DbSet Users { get; set; } public DbSet BlackList { get; set; } public DbSet Inquiry { get; set; } public DbSet InquiryTable { get; set; } public DbSet Lesson { get; set; } public DbSet ContentLessons { get; set; } public DbSet Paragraph { get; set; } public DbSet Solutions { get; set; } public DbSet Success { get; set; } public DbSet Notepad { get; set; } public UserDbContext(DbContextOptions options) : base(options) { } public UserDbContext() : base() { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse").EnableSensitiveDataLogging(); } base.OnConfiguring(optionsBuilder); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().ToTable("user"); modelBuilder.Entity().HasData( new UserEntity(1, "johnny", Convert.ToBase64String(KeyDerivation.Pbkdf2( password: "motdepasse", salt: RandomNumberGenerator.GetBytes(128 / 8), prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Johnny.RATTON@etu.uca.fr", true), new UserEntity(2, "maxime", Convert.ToBase64String(KeyDerivation.Pbkdf2( password: "motdepasse", salt: RandomNumberGenerator.GetBytes(128 / 8), prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Maxime.SAPOUNTZIS@etu.uca.fr", true), new UserEntity(3, "clement", Convert.ToBase64String(KeyDerivation.Pbkdf2( password: "motdepasse", salt: RandomNumberGenerator.GetBytes(128 / 8), prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Clement.CHIEU@etu.uca.fr", true), new UserEntity(4, "erwan", Convert.ToBase64String(KeyDerivation.Pbkdf2( password: "motdepasse", salt: RandomNumberGenerator.GetBytes(128 / 8), prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Erwan.MENAGER@etu.uca.fr", true), new UserEntity(5, "victor", Convert.ToBase64String(KeyDerivation.Pbkdf2( password: "motdepasse", salt: RandomNumberGenerator.GetBytes(128 / 8), prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true)); modelBuilder.Entity().HasKey(c => c.LessonId); modelBuilder.Entity().HasKey(c => c.LessonPartId); modelBuilder.Entity().HasKey(s => s.UserId); modelBuilder.Entity().HasKey(s => s.InquiryId); modelBuilder.Entity().HasKey(s => s.Id); base.OnModelCreating(modelBuilder); } } }