'datetime2' error when using entity framework in VS 2010 .net 4.0

前端 未结 16 1265
半阙折子戏
半阙折子戏 2020-11-29 00:04

Getting this error:

System.Data.SqlClient.SqlException : The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range v

16条回答
  •  被撕碎了的回忆
    2020-11-29 00:59

    I had the same problem and solve it by put the [Column(TypeName = "datetime2")] attribute to related properties, like below sample:

     [Column(TypeName = "datetime2")]
     public DateTime? PropertyName { get; set; }
    

提交回复
热议问题