Overriding function mapping in Entity Framework and how to set SQL Server timezone from application code?

Viewed 23

An application runs on a SQL Server database that runs on a specific timezone, and the entire application EF code and stored procedures rely on that timezone with DateTime.Now and GETDATE().

That same application is being migrated to another SQL Server, which runs on another different timezone that cannot be changed.

What are the strategies to make small changes to this application code to make this migration feasible?

  1. Procedures: create a getdatefix() function wrapping the getdate() and adding the timezone logic. Replace getdate() with getdatefix() in all stored procedures.

  2. EF: is there a way to set timezone from application code? Is there a way to override function mapping so we can override the DateTime.Now mapping from getdate() to getdatefix()?

Any other ideas?

Thanks!

0 Answers
Related