I have a Model League, and the corresponsing SQL Server table has a DateCreated column that uses a default SQL value of getdate().
When I add a new League, the DateCreated column gets written with a null value, which I'm guessing is a result of the EF overwriting the SQL getdate() function. Is there a way to get the EF to ignore this column when adding a new row? Here's my create action:
[HttpPost]
public ActionResult Create(LeagueCreateViewModel lcv)
{
League league = new League();
league.Title = lcv.Title;
league.SiteId = lcv.SiteId;
if (ModelState.IsValid)
{
db.Leagues.Add(league);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.SiteId = new SelectList(db.Sites, "Id", "Title", league.SiteId);
return View(lcv);
}