I have an old query that looks
UPDATE table1 SET date_time_field = NOW() + INTERVAL 5 MINUTE WHERE ...;
How can I do the same in EF ? I cannot write
....
table1_entity.date_time_field = DateTime.Now + TimeSpan.FromMinutes(5);
because the application and DB server may use different timezones. Is it possible to achieve this functionality without native queries (which is my current approach, but I don’t really like it) ?
Thanks.
Add the above method to your datacontext class to get the db server time:
Extracted from this post:
Entity Framework – update field value to current DB server time