I am facing an issue when editing an existing instance of my model Client:
public class Client{
public int ClientID{get;set;}
[DataType(DataType.Date)]
public DateTime dateIn{get;set;}
}
My controller:
[HttpPost]
public ActionResult EditFC(Client client, Connexion connexion)
{
if (ModelState.IsValid)
{
db.Entry(client).State = EntityState.Modified;
var t = client.dateIn;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(client);
}
The error that is thrown is:
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
So I don't know what's it happening my variable is dateTime I display it as a Date and I think it is maybe the problem that is when editing it takes a Date and not a DateTime, maybe I have to do a conversion but I don't how ?