我有一个域实体
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
Run Code Online (Sandbox Code Playgroud)
在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; }
}
Run Code Online (Sandbox Code Playgroud)