The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value

后端 未结 23 1331
旧时难觅i
旧时难觅i 2020-11-28 20:19

I have the following code in my HomeController:

public ActionResult Edit(int id)
{
    var ArticleToEdit = (from m in _db.ArticleSet where m.storyId == id se         


        
23条回答
  •  攒了一身酷
    2020-11-28 20:57

    I got this error after I changed my model (code first) as follows:

    public DateTime? DateCreated
    

    to

    public DateTime DateCreated
    

    Present rows with null-value in DateCreated caused this error. So I had to use SQL UPDATE Statement manually for initializing the field with a standard value.

    Another solution could be a specifying of the default value for the filed.

提交回复
热议问题