我有一个域实体
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
在Id
属性上设置但 EF 在尝试保存时仍尝试插入空值。这是个常见的问题吗?这是它的外观示例。
public class Invoice
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public ShippingInformation ShippingInformation{ get; set; }
public BillingInformation BillingInformation { get; set; }
public decimal Subtotal { get; set; }
public User user { get; set; }
public bool Processed { get; set; }
}