Entity Framework CTP 4. “Cannot insert the value NULL into column” - Even though there is no NULL value

前端 未结 9 1595
情深已故
情深已故 2020-12-05 06:21

Im using EF CTP 4. I have a simple console app (for testing purposes) that is using EF to insert some data into a SQL database.

I have come to a problem where by upo

9条回答
  •  Happy的楠姐
    2020-12-05 07:01

    i have the same issue here and it's really an ugly solution.

     [Key]
    public Int64 PolicyID { get; set; }
    

    this is NOT an auto generated number

    then i hit the same error.

    EF Code First CTP5

    after apply this:

     [Key]
     [DatabaseGenerated(DatabaseGeneratedOption.None)]
     public Int64 PolicyID { get; set; }
    

    then it will work.

提交回复
热议问题