我有三张桌子
ShippingZone
ShippingZoneID -> PK
ZoneShippingMethod:
ZoneShippingMethodID -> PK
ShippingZoneID -> FK
ZoneShippingMethodRange
ZoneShippingMethodID -> FK
上下文:
public ShippingZonesContext()
: base("name=ShippingZonesContext")
{
}
public virtual DbSet<ShippingZone> ShippingZones { get; set; }
public virtual DbSet<ZoneShippingMethod> ZoneShippingMethods { get; set; }
public virtual DbSet<ZoneShippingMethodRange> ZoneShippingMethodRanges { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<ShippingZone>()
.Property(e => e.ZoneCountryIDs)
.IsUnicode(false);
modelBuilder.Entity<ShippingZone>()
.Property(e => e.ZoneStateIDs)
.IsUnicode(false);
modelBuilder.Entity<ShippingZone>()
.HasMany(e => e.ZoneShippingMethods)
.WithRequired(e => e.ShippingZone)
.WillCascadeOnDelete(false);
modelBuilder.Entity<ZoneShippingMethod>()
.Property(e => e.UserID)
.IsUnicode(false);
modelBuilder.Entity<ZoneShippingMethod>()
.Property(e => e.Password)
.IsUnicode(false);
modelBuilder.Entity<ZoneShippingMethod>()
.Property(e => e.ShippingServiceTypeIDs)
.IsUnicode(false);
modelBuilder.Entity<ZoneShippingMethod>()
.Property(e => e.AccessKey)
.IsUnicode(false);
modelBuilder.Entity<ZoneShippingMethod>()
.Property(e => e.ShipperNumber)
.IsUnicode(false);
modelBuilder.Entity<ZoneShippingMethod>()
.HasMany(e => e.ZoneShippingMethodRanges)
.WithRequired(e => e.ZoneShippingMethod)
.WillCascadeOnDelete(false);
}
当前代码:
context.UpdateGraph(shippingZone, map => map
.OwnedCollection(p => p.ZoneShippingMethods).OwnedCollection(p => p.ZoneShippingMethods.FirstOrDefault().ZoneShippingMethodRanges)
);
给出这个错误:
不支持更新映射中使用的方法
有什么线索吗?
感谢和问候。