The conversion of a datetime2 data type to a datetime data type Error

后端 未结 9 1561
慢半拍i
慢半拍i 2020-12-30 08:45

I have a controller:

[HttpPost]
public ActionResult Create(Auction auction)
{
    var db = new EbuyDataContext();
    db.Auctions.Add(auction);
    db.SaveCh         


        
9条回答
  •  一向
    一向 (楼主)
    2020-12-30 09:01

    Does your columns with datetime2 datatype accepts null values. If not then you might get this error when you are not assigning a value to these columns.

    By default the CodeFirst will make non nullable columns if your model does not use nullable properties. Try converting these properties to nullable datetime.

提交回复
热议问题