Bug #61789 Invalid cast from String to Guid
Submitted: 7 Jul 2011 18:50 Modified: 29 Jul 2011 14:43
Reporter: Diego AC Email Updates:
Status: Can't repeat Impact on me:
Category:Connector / NET Severity:S1 (Critical)
Version:6.4.3 OS:Windows
Assigned to: Julio Casal CPU Architecture:Any
Tags: connector net

[7 Jul 2011 18:50] Diego AC
I'm using EntityFramework 4.1 with Connector version 6.4.3 and I'm receiving a nasty Exception stating "Invalid cast from type "System.String" to type "System.Guid", since all my primary keys are Guids, I'm in some big trouble.

This occurs with a set of a parent entity. Whenever I query the parent set it craches, when I query each child set by using Linq's "OfType" method, it works fine. Any idea why is this happening?

BTW, I've already seen the bug reports similar to this from back 2009. Sadly, no patch fix this error for me and using the MySql connector source code requires way too much settings and time.

Any thoughts on this, please?

How to repeat:
- Generate an entity set of a parent class. 
- Query the set, it fails.

Suggested fix:
I guess it has to do with how it converts Guids, at least make MySql datareader ignore the invalid entities so I can work with the good ones.
[8 Jul 2011 4:10] Valeriy Kravchuk
Looks like a duplicate of Bug #61657.
[8 Jul 2011 4:27] Diego AC
I have latest version and the Exception is still thrown.
[11 Jul 2011 11:00] Bogdan Degtyariov

Thanks for reporting the bug. 
We have fixed few issues with GUID back in 2009-2010 and now all our tests pass successfully.

Would you mind making a small test case with table schema to help us repeat the problem? Your instructions in the bug description were a bit obscure and I couldn't make the test failing.
[11 Jul 2011 14:07] Diego AC
I wish I could generate a sample schema for that. The failing entity is a central class with way too many related sub-entities. So I don't even know which of the 13000 records is the one crashing and which of the foreign keys is causing the error.

Anyways, is there any special considerations when using Guids with MySql connector?
[29 Jul 2011 14:43] Julio Casal
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Please attach a small database schema and VS project where this issue appears.

Thank you for your interest in MySQL.