Filed under
In my new e-commerce site, I am using Linq to SQL. In all my tables I have modfiedOn and createdOn datetime columns. When clicking on my "add to cart" button, I want to insert the items into my OrderItem table, but I kept on getting "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. These are set to automatically get the current utc date in my database upon insert like they've always been in the past, so I didn't see a problem. But when stepping through my code, I noticed that these are set to a low value date of 1/1/0001 and sent into the database that way. Ok, starting to make sense, so I set these dates myself through code and it worked, but why should I have to do that?
I played around with the "dbml" designer and found a property called "Auto Generated Value". The description sounded just like what I wanted, "Value is auto-generated in database on insert". Perfect, so I set both of these properties to true, recompiled, and problem solved.
df269d19-8bc5-4ece-92ee-917cb5344382|0|.0