4

Is there any way to specify Entity Framework to convert all DateTime in UTC (for azure database storage) ?

I would like that my model stay in local date time. I don't want to duplicate model datetime properties to have one in UTC (for EF) and another one in local (for my views, not mapped in EF).

Corey Adler
  • 15,897
  • 18
  • 66
  • 80
ZeBobo5
  • 354
  • 4
  • 14
  • You could write a custom saving changes method which uses reflection to find all datetime properties in objects that are going to be saved and convert them there... – Mansfield Nov 07 '13 at 15:42
  • Yes, that's ok for adding or updating to DB but not while reading from DB... – ZeBobo5 Nov 07 '13 at 15:46
  • 1
    Similar problem to http://stackoverflow.com/a/19377226/150342 – Colin Nov 07 '13 at 16:40

1 Answers1

0

That's not directly possible. Either you'll live without it or you'll have to create some "helper" code (properties) in your classes/entities.

cincura.net
  • 4,130
  • 16
  • 40