using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using RazorPagesMovie.Models;

// PM> Remove-Migration
// PM> Add-Migration Init
// PM> Update-Database

namespace FakturyWeb.Data
{
    public class FakturyWebContext : DbContext
    {
        public FakturyWebContext (DbContextOptions<FakturyWebContext> options)
            : base(options)
        {
        }

        public DbSet<RazorPagesMovie.Models.FAKTURA> FAKTURA { get; set; }

        public DbSet<RazorPagesMovie.Models.UZIVATEL> UZIVATEL { get; set; }

        public DbSet<RazorPagesMovie.Models.ZAKAZNIK> ZAKAZNIK { get; set; }

        #region Required
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
          modelBuilder.Entity<FAKTURA>()
              .HasOne(e => e.ZAKAZNIK)
              .WithMany(e => e.Faktury)
              .HasForeignKey(e => e.ZakaznikID)
              .OnDelete(DeleteBehavior.Restrict)
              .IsRequired();
    }
        #endregion
  }
}
