Bug #77887 .NET Connector and EF dont work
Submitted: 30 Jul 2015 15:10 Modified: 22 Sep 2015 17:48
Reporter: Claudia Stölzel Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.6 OS:Windows (EF 5.0 / EF 6.0 )
Assigned to: Roberto Ezequiel Garcia Ballesteros CPU Architecture:Any
Tags: Visual Studio 2013 EF connector

[30 Jul 2015 15:10] Claudia Stölzel
Description:
After installing .NET Connector and MYSql Visual Studio ( 1.2.3 or 1.2.4 does not matter) a connection to MYSql server cannot be established to generate a model in the entity framework. 

there are three different error messages depending on how to get the connection:

How to repeat:
Each try to get a connection and an EF model is done with the wizzard to create a new mysql project. 

First: Exception after have chosen the table(s)/view(S) to get into the EF model:

exception stack: 

Aufgrund der folgenden Ausnahme kann das Modell nicht generiert werden: 'System.Data.Entity.Core.EntityCommandExecutionException: Fehler beim Ausführen der Befehlsdefinition. Weitere Informationen finden Sie in der internen Ausnahme. ---> MySql.Data.MySqlClient.MySqlException: Out of memory (Needed 261104 bytes)
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.Execute(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.EntityCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadDataTable[T](String sql, Func`2 orderByFunc, DataTable table, EntityStoreSchemaFilterObjectTypes queryTypes, IEnumerable`1 filters, String[] filterAliases)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadTableDetails(IEnumerable`1 filters)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadStoreSchemaDetails(IList`1 filters)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GetStoreSchemaDetails(StoreSchemaConnectionFactory connectionFactory)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils, ModelBuilderEngineHostContext hostContext)'.
Das Laden der Metadaten aus der Datenbank dauerte 00:00:02.1247225.
This try refers to EF 5

Second:
EF 6:

The store metadata has not been generated yet. Call GenerateStoreMetaData first. 

Third try: as a follow up from three: try to add an ado.net model via add new item menu:
leads to 

EntityCommandExecutionException

Aufgrund der folgenden Ausnahme kann das Modell nicht generiert werden: 'System.Data.Entity.Core.EntityCommandExecutionException: Fehler beim Ausführen der Befehlsdefinition. Weitere Informationen finden Sie in der internen Ausnahme. ---> MySql.Data.MySqlClient.MySqlException: Out of memory (Needed 261104 bytes)
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.Execute(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.EntityCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadDataTable[T](String sql, Func`2 orderByFunc, DataTable table, EntityStoreSchemaFilterObjectTypes queryTypes, IEnumerable`1 filters, String[] filterAliases)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadTableDetails(IEnumerable`1 filters)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadStoreSchemaDetails(IList`1 filters)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GetStoreSchemaDetails(StoreSchemaConnectionFactory connectionFactory)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils, ModelBuilderEngineHostContext hostContext)'.
Das Laden der Metadaten aus der Datenbank dauerte 00:00:00.7014869.
Die Modellgenerierung dauerte 00:00:34.7342441.

-> similar to first try.

After installing the references vial NugetManager I get the error message that the versions are incompatible.
[31 Jul 2015 7:18] Chiranjeevi Battula
Hello  Claudia Stölzel,

Thank you for the bug report.
I tried to reproduce the issue at my end using Visual Studio 2013 (C#.Net), MySQL Connector/Net 6.9.6 and EntityFramework6.1.3 but not seeing any issue in model creation.
Could you please provide repeatable steps for us to confirm this issue at our end.

Thanks,
Chiranjeevi.
[31 Jul 2015 7:19] Chiranjeevi Battula
screenshot

Attachment: 77887.PNG (image/png, text), 57.05 KiB.

[31 Jul 2015 9:25] Claudia Stölzel
I have a Visual Studio 2013 Update 5 installation on W8.
MySql : Connector Net 6.9.6
Visual Studio 1.2.4.

In Visual Studio I choose 
a)Create New MySql Project 
b)Project Type Windows Forms Project Visual C#
c)Data Source Configuration -> Entity Framework 5.0, Datasource is given and works
Next dialog:
select one table from selected database -> finish
dialog occurs with progress bar:
Project "Blabla" is created , then the error message "The store metadata has not been generated yet. Call GenerateStoreMetadata first." appears , click OK -> no model created.

Repeat step a) and b) 
in step c) choose EF 6 instead of 5.select same table -> Finish. 
Project "Blabla" is created , then the error message "The store metadata has not been generated yet. Call GenerateStoreMetadata first." appears , click OK -> no model created.

Now, go to created project ( without having an entity model) 

a) Add->New Item-> ADO.NET Entity Data Model , 
b) choose EF from database->Next 
c) take given data connection ->Next 
d) dialog with tables, views and procedures occurs
e) choose one table -> Finish
Exception is thrown: 
Aufgrund der folgenden Ausnahme kann das Modell nicht generiert werden: 'System.Data.Entity.Core.EntityCommandExecutionException: Fehler beim Ausführen der Befehlsdefinition. Weitere Informationen finden Sie in der internen Ausnahme. ---> MySql.Data.MySqlClient.MySqlException: Out of memory (Needed 261104 bytes)
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.Execute(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.EntityCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadDataTable[T](String sql, Func`2 orderByFunc, DataTable table, EntityStoreSchemaFilterObjectTypes queryTypes, IEnumerable`1 filters, String[] filterAliases)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadTableDetails(IEnumerable`1 filters)
   at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.EntityStoreSchemaGeneratorDatabaseSchemaLoader.LoadStoreSchemaDetails(IList`1 filters)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GetStoreSchemaDetails(StoreSchemaConnectionFactory connectionFactory)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
   at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils, ModelBuilderEngineHostContext hostContext)'.
Das Laden der Metadaten aus der Datenbank dauerte 00:00:01.1893175.
Die Modellgenerierung dauerte 00:00:24.8469097.

References in poject are:
EntityFramework 6.0.0
MySql.Data 6.9.6.0
MySql.Data.Entity.EF6 6.9.6.0

New repro-scenario:

a) New project - > Windows Form Application
b) Add->New Item-> ADO.NET Entity Data Model , 
c) choose EF from database->Next 
d) take given data connection ->Next 
e) dialog with tables, views and procedures occurs

same exception as above is thrown.
[3 Aug 2015 7:06] Chiranjeevi Battula
Hello  Claudia Stölzel,

Thank you for your feedback.
As per your steps I couldn't reproduce the issue at my end in Windows 8.1 using Visual Studio 2013 (C#.Net), MySQL Connector/Net 6.9.6 and EntityFramework6.1.3.

Thanks,
Chiranjeevi.
[3 Aug 2015 7:06] Chiranjeevi Battula
screenshot

Attachment: 77887_1.PNG (image/png, text), 54.37 KiB.

[3 Aug 2015 12:04] Claudia Stölzel
is it possible to provide as a ZIP file your project ? with all assemblies included ? 
Then I can try to get this running . 
Which server version of MySql did you use ? 

Regards, 

Claudia
[22 Sep 2015 7:12] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=78504 marked as duplicate of this one.
[22 Sep 2015 16:18] SCREW ORACLE
The status of this bug should be changed to something other than "Can't repeat" as I am able to (unintentionally) replicate the issue. My bug report was marked as a duplicate even though there are slight differences (I didn't get an exception w/ a stack trace, just a sudden wizard prompt closure after clicking next from the select connection section). As such I'm re-posting my bug description here for easy reference. On a side note, I also I get an "Exception from HRESULT: 0x80004005 (E_FAIL)" error despite folders not being encrypted when trying to create a project using the MySQL w/ MVC 3 template and trying other solutions on the web.

@Claudia, did you have the same issue in 1.2.2 or below or does it work w/ 1.2.2? I'm working on a time sensitive project and I can't afford to have my customers' project held back because of an issue Oracle hasn't resolved for some time and may take a while to solve and am in desperate need of some work around to get 'Code first from database' to auto-generate everything as I've tried to do it manually and failed thus far to be able to do something like db.someModel.ToList() w/o generating an exception about a terrible db connection config, but no details to determine root cause.

My original issue:

Description:
I have the following in a new ASP.NET MVC5 project:

 - VS2015 Enterprise 14.0.23107.0 D14REL
 - MySQL for VisualStudio 1.2.4
 - Connector/NET 6.9.7

Nuget:

 - EntityFramework 6.1.3
 - MySql.Data 6.9.7
 - MySql.Data.Entities 6.8.3
 - MySql.Web 6.9.7

And have the following in Web.config:

      <entityFramework>
        <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
        <providers>
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
        </providers>
      </entityFramework>

Within Server Explorer I have a valid connection to a remote MySql Server instance and ability to read/write tables, etc. However, when I try to add an ADO.NET entity and select 'Code first from database', hit next, select the connection, mark "Yes, include the sensitive data in the connection string" and leave the "Save connection settings Web.Config as:" checked as well as the default name in the textfield and then hit next, Visual Studio seems to think a bit, shows a blank wizard panel (http://i.stack.imgur.com/Ezm4L.png) real quick, and then the wizard closes rather than bringing up a panel to select table objects, etc. Furthermore there are no models created nor is there a `connectionString` created in Web.config despite the wizard closing. I get the same issue with using a local MySql Server instance as well.

How to repeat:
Use the following in/with a new ASP.NET MVC5 project:

 - VS2015 Enterprise 14.0.23107.0 D14REL (might be possible to use another version)
 - Win8.1 x64 (might be able to use another version)
 - MySQL for VisualStudio 1.2.4
 - Connector/NET 6.9.7

Nuget:

 - EntityFramework 6.1.3
 - MySql.Data 6.9.7
 - MySql.Data.Entities 6.8.3
 - MySql.Web 6.9.7

And have the following in Web.config:

      <entityFramework>
        <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
        <providers>
          <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
        </providers>
      </entityFramework>

Connect to a local/remote MySql instance using Server Explorer in VS and confirm you have read/write access. Try adding a ADO.NET entity using 'Code first from database' and using the MySql database in question. Click next. Instead of wizard panel with ability to expand database and select tables to use for model creation, the wizard should close unexpectedly.

Suggested fix:
Unknown
[22 Sep 2015 17:48] Claudia Stölzel
@SCREW ORACLE 
I did not try with 1.2.2 I was/ am in the same situation as you are. My customer was/is expecting a working client to connect to a MySQL database in internet. 
So we decided to work with an older technique than the entity framework to connect to MySQL. 
But I did not find any solution in the internet for this problem. I only found more people with the same or similar issues. 

I also would be very happy if I could get an example solution but unfortunately Chiranjeevi Battula or someone else does not provide me the solution that is working for him/her. 

In my opinion this issue is not solved. 
I would be happy if you can inform me if you find a solution.
[22 Sep 2015 18:58] SCREW ORACLE
@Claudia can you provide a link to the technique you referenced or some sort of ASP.NET MVC <-> MySql sample project to download? I've tried a couple of other VS && MySql4VS versions and still got the same issue and am at wits ends as to how to get a proper model based on MySQL table, and proper connection to table since all of the modern tutorials reference using EF Designer/Code first from database rather than how to do it manually.

It almost sounds like the root cause somehow lies with Win8/Win8.1 (x64 in my case) given that's the only thing that's constant in both Claudia's case and my case. I've further replicated the issue by using VS2013 Ultimate (latest version) with MySql4VS 1.1.4 (doesn't support VS2015 going by the release log) and I suspect given the only real control variable being the OS (Win8/8.1 [x64?]) trying different VS && MySql4VS versions will still result in replicating the issue.
[30 Aug 2016 15:27] Jason Work
I know this is an old bug, but I had a similar situation and fix.

I also have the same problem of creating the code-first entity framework with the wizard, and having it immediately disappear after picking the DB, what to include in the connection string, etc.

I realized I had accidentally added two MySql.Data.Entity nuget packages to my project.  One was created by MySql and the other was created by Oracle.  I uninstalled the MySql version, and now it goes forward like normal.  I assume the problem is having two MySql.Data.Entity nuget packages installed at the same time, and removing one or the other should let you proceed in the wizard.

In a separate project I had the same problem, and I also had to remove the reference in the app.config file (this particular project was just a test console app).  The two versions were reference under <entityFramework><provider>...