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

后端 未结 9 1594
慢半拍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 08:57

    This post - Solution to: “The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value” with Entity Framework when calling SaveChanges - proposes to use the attribute. It solved the issue for me.

    [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
    public Nullable Created { get; set; }
    

提交回复
热议问题