I am using Entity Framework EDM model with dotConnect for PostgreSQL. One of the entity properties is of type DateTime and maps to a timestamptz column in the database. I can't use DateTimeOffset because EDM doesn't support that mapping.
If I assign a DateTime with Kind = Utc to the property, the Kind is ignored when the data is stored to the database.
For example, if I have a DateTime '2016-04-01 22:10' and Kind = Utc, it ends up in the database as '2016-04-01 22:10 -6' (I'm in Mountain tz). When I later query it, the property is now a DateTime '2016-04-01 22:10' with Kind = Local, which is incorrect.
Is it supposed to work this way? I saw an old post that seemed related, but it was about Kind being dropped on reading the data, not writing it.
DateTime.Kind ignored when writing to database
-
- Posts: 10
- Joined: Wed 29 Jun 2016 13:34
Re: DateTime.Kind ignored when writing to database
We recommend you to use Entity Developer (Devart Entity Model, *.edml) instead of EDM Designer (ADO.NET Entity Data Model, *.edmx) because it is adjusted for working with PostgreSQL and has an advanced functionality: http://www.devart.com/entitydeveloper/ed-vs-edm.html. Additionally, Entity Developer supports DateTimeOffset.
You can migrate your existing *.edmx to *.edml, just open *.edmx with Entity Developer and save model (as *.edml). Entity Developer allows only to import *.edmx but the output would be *.edml. Output can not be *.edmx because Entity Developer uses extra tags and attributes, additional features which are not supported by EDM Designer.
Does this help?
You can migrate your existing *.edmx to *.edml, just open *.edmx with Entity Developer and save model (as *.edml). Entity Developer allows only to import *.edmx but the output would be *.edml. Output can not be *.edmx because Entity Developer uses extra tags and attributes, additional features which are not supported by EDM Designer.
Does this help?