effkay
effkay

Reputation: 854

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?

Upvotes: 9

Views: 9597

Answers (2)

Pankaj Singh
Pankaj Singh

Reputation: 71

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

Upvotes: 5

sirrocco
sirrocco

Reputation: 8055

@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.

Upvotes: 12

Related Questions