title: 'datetime2' error when using entity framework in VS 2010 .net 4.0
body: <p>Getting this error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException : The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.</p>
  </blockquote>
  
  <p>My entity objects all line up to the DB objects.</p>
  
  <p>I found only a single reference to this error via Google:</p>
  
  <p><a href="http://ramonaeid.spaces.live.com/blog/cns!A77704F1DB999BB0!182.entry" rel="noreferrer">Google result</a></p>
  
  <p>After reading this, I remember that we <em>did</em> add 2 fields and then updated the entity model from VS 2010.  I'm not sure what he means by "hand coding" the differences.  I don't see any.</p>
  
  <p>All I'm doing in code is populating the entity object and then saving. (I also populate the new fields in code)  I populated the date field with <code>DateTime.Now</code>..</p>
  
  <p>The important part of the code is this:  <code>ctx.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);</code></p>
  
  <p>The database is SQL Server 2008.</p>
  
  <p><strong><em>Thoughts?</em></strong></p>
  
  <p>The rest of the error:</p>
  
  <blockquote>
    <p>at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
    at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
    at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
    at SafariAdmin.Site.WebServices.SpeciesPost.SaveOrUpdateSpecies(String sid, String fieldName, String authToken) in SpeciesPost.svc.cs: line 58
    at SafariAdmin.TestHarness.Tests.Site.WebServices.SpeciesPostSVC_Tester.SaveNewSpecies() in SpeciesPostSVC_Tester.cs: line 33
    --SqlException
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
    at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary<code>2 identifierValues, List</code>1 generatedValues)
    at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) </p>
  </blockquote>