我在这里拔头发。我在这里看到了在删除时关闭级联的解决方案,但我无法实现。我不知道我在这里做错了什么,但我不断收到以下错误:
“System.Data.Entity.ModelConfiguration.EntityTypeConfiguration”不包含“WillCascadeOnDelete”的定义,并且没有扩展方法“WillCascadeOnDelete”接受“System.Data.Entity.ModelConfiguration.EntityTypeConfiguration”类型的第一个参数(你是缺少 using 指令或程序集引用?)
我已经添加了必要的命名空间,但我不认为它是智能感知中的任何地方的一个选项,而且我没有在任何地方搜索。我在 VS 2010 MVC 3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using vf2.Models;
using vf2.Models.LinkTables;
using vf2.Models.Requests;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.ModelConfiguration.Configuration;
using System.Data.Entity.ModelConfiguration;
using vf2.Models.Reporting;
using vf2.Models.POSObj;
namespace vf2.Models
{
public class vfContext : DbContext
{
public DbSet<App> Apps { get; set; }
public DbSet<Origin> Origins { get; set; }
public DbSet<WineType> WineTypes { get; set; }
public DbSet<VarType> VarTypes { get; set; }
public DbSet<Wine> Wines { get; set; }
public DbSet<Vintage> Vintages { get; set; }
public DbSet<Distributor> Distributors { get; set; }
public DbSet<Importer> Importers { get; set; }
public DbSet<Producer> Producers { get; set; }
public DbSet<Publication> Publications { get; set; }
public DbSet<Review> Reviews { get; set; }
public DbSet<UserType> UserTypes { get; set; }
public DbSet<Restaurant> Restaurants { get; set; }
public DbSet<WineListChangeRate> WineListChangeRates { get; set; }
public DbSet<MenuChangeRate> MenuChangeRates { get; set; }
public DbSet<WineListCount> WineListCounts { get; set; }
public DbSet<UserObj> UserObjs { get; set; }
public DbSet<ProducerUser> ProducerUsers { get; set; }
public DbSet<DistributorUser> DistributorUsers { get; set; }
public DbSet<RestaurantUser> RestaurantUsers { get; set; }
public DbSet<ProducerEditRequest> ProducerEditRequests { get; set; }
public DbSet<RequestStatus> RequestStatuses { get; set; }
public DbSet<VOAVIRequest> VOAVIRequests { get; set; }
public DbSet<POS> POSs { get; set; }
public DbSet<Cart> Carts { get; set; }
public DbSet<FutureUser> FutureUsers { get; set; }
public DbSet<Doc> Docs { get; set; }
public DbSet<DocType> DocTypes { get; set; }
public DbSet<WineVisit> WineVisits { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Review>().WillCascadeOnDelete(false);
//error here!
base.OnModelCreating(modelBuilder);
}
}
}