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.7 KiB
47 lines
1.7 KiB
using DTO;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace EntityFramwork
|
|
{
|
|
public class BDDContext : DbContext
|
|
{
|
|
|
|
public BDDContext() { }
|
|
public BDDContext(DbContextOptions<BDDContext> option) : base(option) { }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
//création de la table Champion
|
|
modelBuilder.Entity<EntityChampions>().HasKey(a => a.Id);
|
|
modelBuilder.Entity<EntityChampions>().Property(a => a.Id)
|
|
.ValueGeneratedOnAdd();
|
|
|
|
//création de la table Skins
|
|
modelBuilder.Entity<EntitySkins>().HasKey(m => m.Id);
|
|
modelBuilder.Entity<EntitySkins>().Property(m => m.Id)
|
|
.ValueGeneratedOnAdd();
|
|
|
|
//modelBuilder.Entity<EntitySkins>().Property<int>("ChampionForeignKey");
|
|
// Use the shadow property as a foreign key
|
|
/*
|
|
modelBuilder.Entity<EntitySkins>()
|
|
.HasOne(m => m.Champion)
|
|
.WithMany(a => a.Skins)
|
|
.HasForeignKey("ChampionsForeignKey");*/
|
|
}
|
|
|
|
public DbSet<EntityChampions> Champions { get; set; }
|
|
public DbSet<EntitySkins> Skins { get; set; }
|
|
public DbSet<EntityLargeImage> Images { get; set; }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
optionsBuilder.UseSqlite($"Data Source=C:\\Users\\Jolys Enzo\\home\\BUT\\Projet\\LOL-API\\Sources\\EntityFramwork\\BDD-APILOL.db");
|
|
}
|
|
}
|
|
}
|
|
} |