| 12345678910111213141516171819202122232425262728293031323334 |
- using Domain;
- using Domain.Weapons;
- using Microsoft.EntityFrameworkCore;
- namespace DataLayer;
- public class DeathwatchDbContext : DbContext
- {
- public DbSet<Player> Players { get; set; }
- public DbSet<Weapon> Weapons { get; set; }
- public DeathwatchDbContext() : base()
- {
- }
- public DeathwatchDbContext(DbContextOptions<DeathwatchDbContext> options) : base(options)
- {
- }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (!optionsBuilder.IsConfigured)
- {
- //optionsBuilder.UseSqlServer("Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=ReadersDB");
- }
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Player>().HasMany(s => s.Weapons);
- modelBuilder.Entity<Weapon>().HasMany(w => w.Players);
- }
- }
|