using Entities; using Microsoft.EntityFrameworkCore; namespace DbConnectionLibrairie { public class MyDbContext : DbContext { public DbSet Administrators { get; set; } public DbSet Answers { get; set; } public DbSet Chapters { get; set; } public DbSet Lobbies { get; set; } public DbSet Players { get; set; } public DbSet Questions { get; set; } public DbSet Use { get; set; } public DbSet Play { get; set; } public MyDbContext() { } public MyDbContext(DbContextOptions contextOptions) : base(contextOptions) { } protected override void OnConfiguring(DbContextOptionsBuilder options) { if (!options.IsConfigured) { options.UseSqlite(@"Data source = database.db"); } } /// /// function overrided OnModelCreating : /// initialise composed primary keys /// /// protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasKey(u => new { u.IdLobby, u.IdPlayer }); modelBuilder.Entity().HasKey(u => new { u.IdPlayer, u.IdChapter }); base.OnModelCreating(modelBuilder); } } }