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.
47 lines
1.8 KiB
47 lines
1.8 KiB
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Shared;
|
|
using System.Reflection.Metadata;
|
|
using System.Security.Claims;
|
|
using System.Xml.Linq;
|
|
|
|
namespace Entities
|
|
{
|
|
public class LolDbContext : DbContext
|
|
{
|
|
public DbSet<SkinEntity> skins { get; set; }
|
|
public DbSet<ChampionEntity> champions { get; set; }
|
|
public DbSet<CharacteristicEntity> characteristics { get; set; }
|
|
public DbSet<SkillEntity> skills { get; set; }
|
|
public DbSet<RuneEntity> runes { get; set; }
|
|
public DbSet<RunePageEntity> runepages { get; set; }
|
|
public DbSet<LargeImageEntity> largeimages { get; set; }
|
|
public LolDbContext(DbContextOptions configuration) : base(configuration){}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured) {
|
|
Console.WriteLine("!IsConfigured...");
|
|
optionsBuilder.UseSqlite($"Data Source=Entities.Champions.db");
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
|
|
modelBuilder.Entity<LargeImageEntity>().Property(e => e.Id).ValueGeneratedOnAdd();
|
|
modelBuilder.Entity<CharacteristicEntity>().HasKey(c => new { c.Name, c.ChampionForeignKey });
|
|
|
|
modelBuilder.Entity<RunePageEntity>().Property(e => e.Id).ValueGeneratedOnAdd();
|
|
modelBuilder.Entity<RunePageEntity>()
|
|
.HasMany(x => x.runes)
|
|
.WithMany(x => x.runepages)
|
|
.UsingEntity<RunePageRuneEntity>();
|
|
|
|
modelBuilder.Entity<ChampionEntity>()
|
|
.HasMany(x => x.runepages)
|
|
.WithMany(x => x.champions);
|
|
}
|
|
}
|
|
}
|