Bug #61076 TIMESPAN is mapped to DateTimeOffset instead of DateTime in Entity Framework
Submitted: 6 May 2011 8:15 Modified: 11 Jun 2019 20:42
Reporter: Markus Wolters Email Updates:
Status: Can't repeat Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.3.6, 6.9.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: datetime, DateTimeOffset, entity framework, TIMESPAN

[6 May 2011 8:15] Markus Wolters
The MySQL Datatype TIMESPAN is mapped to DateTimeOffset when generating entity model. In my opinion this is wrong, because TIMESPAN ist handled as a date, so it should be mapped to DateTime.

Reason: Only with DateTime it's possible to use DateTime Methods like "Day", "Month" and so within LINQ queries.

How to repeat:
1. Create a table with a column of type "TIMESPAN".
2. Generate ADO.NET Entity model out of database with this table.
3. Column of MySQL type "TIMESPAN" is mapped to "DateTimeOffset".

Suggested fix:
Change mapping of TIMESPAN from DateTimeOffset to DateTime.
[13 May 2011 15:33] Valeriy Kravchuk
Please, provide the exact CREATE TABLE statement to use. 

What MySQL server version do you use?
[13 Jun 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Jul 2015 20:09] Eduardo Rivera
I have a problem and i think is related to this issue.

I am using Connector 6.9.6. My Mysql-database has a table with a timestamp column that is mapped to a System.DateTime. This should be mapped to DateTimeOffset type. How can i handle this?. 

[21 Jul 2015 8:08] Chiranjeevi Battula
Hello Eduardo Rivera,

Thank you for the bug report.
I tried to reproduce the issue at my end using Visual Studio 2013 (C#.Net), MySQL Connector/Net 6.9.6 but not seeing any issue in timestamp column mapping.
Could you please provide repeatable steps for us to confirm this issue at our end.

[21 Jul 2015 8:08] Chiranjeevi Battula

Attachment: 61076.PNG (image/png, text), 31.01 KiB.

[23 Jul 2015 22:19] Eduardo Rivera
Indeed, a MySQL timestamp field is mapped to a DateTime. Is it correct?

It should be mapped to DateTimeOffset.
[24 Jul 2015 10:03] Chiranjeevi Battula
Hello Eduardo Rivera,

Thank you for your feedback.
Verified this behavior on Visual Studio 2013 (C#.Net) with MySQL Connector/Net 6.9.6.

[11 Jun 2019 20:42] Daniel Valdez
Posted by developer:
TIMESTAMP datatype is already mapped to DATETIME in EntityFramework. Verified using C/NET 6.10.8.