达人们看看EF(Entity Framework)里一对关系体现报错 5
Supplier表[Key]publicintID{get;set;}//供应商代码[Required,StringLength(50)]publicstringSupp...
Supplier表
[Key]
public int ID { get; set; }
//供应商代码
[Required, StringLength(50)]
public string SupplierCode { get; set; }
//供应商名称
public string SupplierName { get; set; }
//供应商是否可用状态,是否冻结
[Required]
public bool Enabled { get; set; }
//供应商地址
[StringLength(500)]
public string SupplierAddress { get; set; }
//供应商联系人
[StringLength(100)]
public string SupplierContact { get; set; }
//供应商联系电话
[StringLength(100)]
public string SupplierTel { get; set; }
//供应商联系邮件地址
[StringLength(100)]
public string SupplierEmail { get; set; }
[StringLength(500)]
public string Remark { get; set; }
//供应商付款方式
public virtual Payment Payment { get; set; }
payment 表
[Key]
public int ID { get; set; }
//零件品类码
[Required, StringLength(50)]
public string PaymentName { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual ICollection<Supplier> Suppliers { get; set; }
flutapi
modelBuilder.Entity<Payment>()
.HasMany(z => z.Suppliers)
.WithOptional(zz => zz.Payment)
.Map(x => x.MapKey("PaymentID"));
老是报one to more 错误 展开
[Key]
public int ID { get; set; }
//供应商代码
[Required, StringLength(50)]
public string SupplierCode { get; set; }
//供应商名称
public string SupplierName { get; set; }
//供应商是否可用状态,是否冻结
[Required]
public bool Enabled { get; set; }
//供应商地址
[StringLength(500)]
public string SupplierAddress { get; set; }
//供应商联系人
[StringLength(100)]
public string SupplierContact { get; set; }
//供应商联系电话
[StringLength(100)]
public string SupplierTel { get; set; }
//供应商联系邮件地址
[StringLength(100)]
public string SupplierEmail { get; set; }
[StringLength(500)]
public string Remark { get; set; }
//供应商付款方式
public virtual Payment Payment { get; set; }
payment 表
[Key]
public int ID { get; set; }
//零件品类码
[Required, StringLength(50)]
public string PaymentName { get; set; }
[StringLength(500)]
public string Remark { get; set; }
public virtual ICollection<Supplier> Suppliers { get; set; }
flutapi
modelBuilder.Entity<Payment>()
.HasMany(z => z.Suppliers)
.WithOptional(zz => zz.Payment)
.Map(x => x.MapKey("PaymentID"));
老是报one to more 错误 展开
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询