Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework - MySQL - Datetime format issue

I have a simple table with few date fields.

Whenever I run following query:

var docs = ( from d in base.EntityDataContext.document_reviews
select d ).ToList();

I get following exception:

Unable to convert MySQL date/time value to System.DateTime. 
MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime

The document reviews table has two date/time fields. One of them is nullable.

I have tried placing following in connection string:

Allow Zero Datetime=true;

But I am still getting exception.

Anyone with a solution?

like image 729
effkay Avatar asked Dec 14 '09 18:12

effkay


2 Answers

@effkay - if you solved this it would be great if you could post the answer.

Also if anyone else has a solution that would be great too :).

Edit:

The solution can be found in the http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html connector documentation.

I needed to set "Convert Zero Datetime" to true, and now it works.

hth.

like image 116
sirrocco Avatar answered Sep 23 '22 17:09

sirrocco


You need to set Convert Zero Datetime=True in connection string of running application

like image 5
Pankaj Singh Avatar answered Sep 20 '22 17:09

Pankaj Singh