Reputation: 3031
I have a datetime2 column configured by EF 4.3.1 code first. I just noticed that when I update my entity using DateTime.Now the value updated/inserted into SQL Server 2008 is off by 12 hours.
Any ideas where or why this is happening? The system time on my machine is correct and all of my stored procedures that I call directly and use GETDATE() work as expected.
Baffled.
One more thing to note. The DateTime is correct all the way before context.savechanges is called. Something EF is doing or the way EF is passing it to SQL Server is getting mixed up.
Upvotes: 1
Views: 208
Reputation: 6713
From MSDN: GETDATE() Returns the current database system timestamp as a datetime value without the database time zone offset.
Most likely the cause of your problem is related to it.
Upvotes: 1