using Microsoft.EntityFrameworkCore; using Blueprint.Core.Entities; namespace Blueprint.Infra.Database { public class MyDbContext: DbContext { public MyDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(); modelBuilder.Entity() .HasOne(a => a.Category) .WithMany(u => u.Products) .HasForeignKey(w => w.CategoryId).OnDelete(DeleteBehavior.Cascade); new DbInitializer(modelBuilder).Seed(); } } }