我有两个实体:
public partial class Web_Vendor
{
public string VendorID { get; set; }
public virtual Deal_Brands DealBrand { get; set; }
}
public partial class Deal_Brands
{
public string Brand { get; set; }
public virtual Web_Vendor WebVendor { get; set; }
}
我需要使用字段VendorID <-> Brand
使用流畅的API配置一对一映射。
modelBuilder.Entity<Web_Vendor>().HasOptional(x=>x.DealBrand).WithRequired(x=>x.WebVendor).
Map(x=>x.MapKey(""))
任何人都可以帮忙继续这条线吗?
答案 0 :(得分:2)
查看你的课程,我发现Deal_Brands
和Deal_Brands
之间的关系是“一对一”(1-0.1)而不是“一对一”。这意味着Web_Vendor
主键必须是public partial class Web_Vendor
{
public string VendorID { get; set; }
public virtual Deal_Brands DealBrand { get; set; }
}
public partial class Deal_Brands
{
public string VendorID { get; set; }
public string Brand { get; set; }
public virtual Web_Vendor WebVendor { get; set; }
}
主键。这些类将是这样的:
modelBuilder.Entity<Web_Vendor>()
.HasKey(i => i.VendorID);
modelBuilder.Entity<Deal_Brands>()
.HasKey(i => i.VendorID);
modelBuilder.Entity<Web_Vendor>()
.HasOptional(x=>x.DealBrand)
.WithRequired(x=>x.WebVendor);
映射:
acl content_present req_len gt 0
tcp-request content accept if content_present
希望它有所帮助!