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 options) : base(options) { } public DbSet FAKTURA { get; set; } public DbSet UZIVATEL { get; set; } public DbSet ZAKAZNIK { get; set; } #region Required protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasOne(e => e.ZAKAZNIK) .WithMany(e => e.Faktury) .HasForeignKey(e => e.ZakaznikID) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); } #endregion } }