Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 524813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:36:25+00:00 2026-05-13T08:36:25+00:00

When calling context.SaveChange() , I get an exception: {An error occurred while updating the

  • 0

When calling context.SaveChange(), I get an exception: {"An error occurred while updating the entries. See the InnerException for details."} with an InnerException of "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."

Generally this error is pretty easy to fix — just find the DateTime property whose value was never set (defaulted to MinValue). Unfortunately, I checked all properties on my object, and all of them are set to valid dates/times.

Is there some way to figure out which property EF is referring to when throwing this exception?

Also, I’m only actually checking the object I added to the context right before SaveChanges (and as far as I know, I’m only adding 1). Is there a way to look at all pending data that is about to be saved?

Edit

InnerException.StackTrace:

at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value)
at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value)
at System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb)
at System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Byte scale, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc)
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`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)

Edit 2

It may have to do something with my work flow… For example…

  • I build object SalaryInformation in the class responsible for building Entity objects
  • SalaryInformation has an Employee property on it, but the class that builds it only knows the Employee ID, so it sets SalaryInformation.Employee = new Employee { ID = 1 } (leaving the date fields set to MinValue)
  • I pass the SalaryInformation object into a method to be saved
  • Inside the save method, I look up the Employee object in the database based on the ID and then assign the returned Employee object to SalaryInformation.Employee
  • I then context.AddToSalaryInformation(SalaryInformation) and context.SaveChanges()

I suspect this is leaving a straggler Employee behind in the context with only the ID set, and no Dates, thus the error.

Edit 3

Indeed, workflow was the issue. If I simply say `SalaryInformation.Employee = null;’ before assigning the employee object from the database, then the straggler goes away, and no error occurs.

Is this the intended behavior and work around? It seems quite terrible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:36:26+00:00Added an answer on May 13, 2026 at 8:36 am

    You are setting the employee the wrong way. The simplest way to do this is:

    SalaryInformation.Employee = context.Employees.Where(e => e.Id == 1).First();
    context.AddToSalaryInformation(SalaryInformation);
    

    That means a DB access.

    In EF 4, with FK associations, you can do:

    SalaryInformation.EmployeeId = 1;
    context.AddToSalaryInformation(SalaryInformation);
    

    In EF 1, a workaround is:

    SalaryInformation.EmployeeReference.EntityKey = 
        new EntityKey("MyEntities.Employees", "Id", 1);
    context.AddToSalaryInformation(SalaryInformation);
    

    But creating a stub, like you do in your second example, requires additional work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A correct one: I made this one. A complete class.… May 14, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer Memory seems like the best way to go - iff… May 14, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer This is an anonymous method in C#. It's technically the… May 14, 2026 at 10:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.