这是我现在的模型构建器,但是当我删除用户时,它会将食谱用户 ID 设置为空。
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().HasMany(e => e.Recipes).WithOne(e => e.ApplicationUser)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Recipe>().HasOne(e => e.ApplicationUser).WithMany(e=>e.Recipes)
}