【发布时间】:2019-11-13 05:04:36
【问题描述】:
如何使表“PRODUCT”的外键接受空值?
我要求您在填写 PRODUCT 表单时可以保存信息,而无需选择银行。我使用 实体框架
生成表单 PRODUCT(Controller)外键del模型Product -> "public int EntidadID { get; set; }"
我有两个相关的模型。
public class Product
{
[Key]
public int ProductID { get; set; }
public string NumContrato { get; set; }
public float TasaReal { get; set; }
public decimal Capital { get; set; }
public DateTime FechaValor { get; set; }
public DateTime FechaVencimiento { get; set; }
public int Plazo { get; set; }
public int BankID { get; set; }
public virtual CATbank CATbank { get; set; }
}
public class CATbank
{
[Key]
public int BankID { get; set; }
public string Name { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
【问题讨论】:
标签: c# asp.net-mvc entity-framework