小编Fit*_*ure的帖子

无法将值NULL插入列BLAH表BLAH列不允许空值.INSERT失败

我有一个域实体

[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)

entity-framework entity-framework-5

1
推荐指数
1
解决办法
3976
查看次数