using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using WebVentaCoche.Models; namespace WebVentaCoche.DataBase { public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext(DbContextOptions options) : base(options) { } public DbSet Products { get; set; } public DbSet Users { get; set; } public DbSet Orders { get; set; } public DbSet OrderDetails { get; set; } public DbSet
Addresses { get; set; } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity
() .HasOne(a => a.User) .WithMany(u => u.Addresses) .HasForeignKey(a => a.UserId) .OnDelete(DeleteBehavior.Cascade); } } }