I am new to using MySQL and Entity Framework and came across a issue when importing a stored procedure into the edmx file. In the image below you can see that the EDM type column has listed all the columns I'm returning from the SP are listed as "Not Supported". If I go ahead and click Ok in the window it will generate the Complex type class; however, the class file will not have any properties in it.
Is there a way to fix this? I have google and searched stack overflow quite a bit. The only solutions I have read are to manually generate the class files and call the SP manually as well, or to modify the edmx file by hand.
解决方案
Appears to be an issue as noted here http://bugs.mysql.com/bug.php?id=79180 as recently as a week..ago.
I am manually editing the edmx directly to ADD the properties to the ComplexType that was autogenerated, and to ADD the ScalarProperties in the return mapping of the FunctionImportMapping section that was autogenerated..
After doing these manual edits, I can now call my SP using the standard EF model and I get all the rows and columns returned as such (the below example works now for me, where prior to manually changing the edmx file, all I got back were empty Objects in a list - one object per row returned - no data)
using (var context = new therinksEntities())
{
ObjectResult rdrs = context.getGLDistSection("AIM", "Deferred", "2015-07-01", "2015-09-30");
int i = 0;
foreach (getGLDistSection_Result result in rdrs)
{
NonBlockingConsole.WriteLine(i++ + ":" +
result.glaccount + ":" +
result.posteddate + ":" +
result.customername + ":" +
result.category + ":" +
result.description + ":" +
result.debit + ":" +
result.credit + ":" +
result.balance);
}
}
I am using VS 2015, and packages - EF 6.1.3, MySql.Data 6.9.8, MySql.Data.Entit 6.9.8
MySql Database Version MySql 5.5.46-log
Its a painful workaround if many SP's are needed to be used. But, by modifying the edmx and saving and verifying.. all the correct code gets generated along with the properties - so no manual classes or additional properties need to be created.