title: Entity Framework setting Auto DateTime Column to: 01/01/0001 00:00:00
body: <p>I have a MS SQL Srver 2005 Database, that has a table with a DatTime column. The DateTime column is of <strong>smalldatetime</strong> type. The date and time is auto generated by the DB using <strong>getdate()</strong> function. This is because its a LOG recording table, so logs are just inserted and date-time is generated by the db.</p>
  
  <p>When creating a log and saving into the DB through Entity Framework, using LINQ query, it causes an error while saving saying:</p>
  
  <p><strong>"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."</strong></p>
  
  <p>upon investigating using breakpoints i have noticed, when Entity Framework tries to save the Log object, the date set by Entity Framework is set to:</p>
  
  <p><strong>01/01/0001 00:00:00</strong></p>
  
  <p>I guess this is why error is coming up. Is there any way to resolve this?</p>
  
  <p>I am using .Net 3.5 framework.</p>
  
  <p>Regards.</p>