Bug #67668 ObjectContext.ExecuteStoreQuery refuses to run with MySqlParameter
Submitted: 21 Nov 2012 21:33 Modified: 28 Feb 2013 22:48
Reporter: Mike Reust Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.6.4 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any

[21 Nov 2012 21:33] Mike Reust
Description:
I recently upgraded from MySQL .NET Community Connector from 6.5.4 to 6.6.4.

All of my calls to System.Data.Objects.ObjectContext.ExecuteStoreQuery that use parameters are now failing.  This is entity framework v4.0

How to repeat:
Here is a simplified version of my code:

------------
var database = new ObjectContext();
var idParameter = new MySqlParameter("@id", System.Data.SqlDbType.Int);
idParameter = 10;

var sql = "select * from someTable where id = @id";
var result = database.ExecuteStoreQuery<myObject>(sql, idParameter);
------------

This code works fine with 6.5.4.  But with 6.6.4 I get the following exception:

Type: MySql.Data.MySqlClient.MySqlException
Message: "Only MySqlParameter objects may be stored"
ErrorCode: -2147467259

Suggested fix:
Unsure
[26 Nov 2012 14:09] YG Park
I was getting the same error. I downgraded the driver on our servers to v6.5.4 for now.
[29 Jan 2013 22:48] Fernando Gonzalez.Sanchez
Hi,

The code provided does not compile (not in Connector/NET 6.6.x nor in SqlClient), the line

idParameter = 10;

must be changed to 
idParameter.Value = 10;

After this the code works fine in Connector/NET 6.6.5.

Notice that is better to use MySql types than SQL server types in 
var idParameter = new MySqlParameter("@id", MySqlDbType.Int32);
instead of 
var idParameter = new MySqlParameter("@id", System.Data.SqlDbType.Int);
but that works fine too.
[1 Mar 2013 1: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".