6

i'm working in a new project with c# and we want to use entity framework 6 but everytime we want to generate the models based on the database we have in usage. But when i'm generating a ADO.Net model using the wizard, after i select the database and the entity framework i click on the "next" button and instead appear the window to select the tables , the windows disappear without any type of error.

I'm using visual studio 2017 community edition and i've installed the mysql connector v.8.0.11. If i downgrade the mysql connector version and entity framework to v5 everything works without any problem, but after i update the connector and entity framework to version 6.* i get the problem i've reported above.

1
  • Hi, have you found any solution ? Commented Jul 4, 2018 at 10:23

5 Answers 5

11

So after struggling for 3 days myself I FINALLY found the problem...

So the MySql.Data and MySql.Data.Entity that you have to download from NuGet packages versions are directly correlated with the version of the MySql Connector/NET that have to download.

And when you go look the latest version of MySql.Data.Entity is 6.10.7, so this means when download Connector/NET 8 then there is a version incompatibility which results in the ADO.Net data entity wizard closing.

Download the following and BAM it works:

MySql for visual studio 
MySql Connector/NET v6.10.7   

NuGet packages:

Entityframework v6.1.3    
MySql.Data v6.10.7    
MySql.Data.Entity v6.10.7 
Sign up to request clarification or add additional context in comments.

4 Comments

I had to do this way as well. I think it has to do with the db version in my case.
that worked for me and you can download the connector from here downloads.mysql.com/archives/c-net
That was really helpful, I went for 6.10.8 version for connector & both packages. It worked!.. The thing is versions must be exactly same!
4

One thing worth to note:

You will need different Mysql EntityFramework Package for the Mysql version 6 and version 8. (This maybe why the poster has downgraded his/her mysql connector from 8 to 6)

If your mysql connector is version 8.x.x, You may need to install this NuGet Package: https://www.nuget.org/packages/MySql.Data.EntityFramework/

If you mysql connector is version 6.x.x you will need: https://www.nuget.org/packages/MySql.Data.Entity/

And install exactly the same version as your mysql connector. Otherwise, something will not work.

Comments

2

I was able to fix this problem with following config at Web.config

<entityFramework>
  <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.11.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
  </providers>
</entityFramework>
<system.data>
  <DbProviderFactories>
    <remove invariant="MySql.Data.MySqlClient" />
    <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.11.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D" />
  </DbProviderFactories>
</system.data>

Also I referenced to:

Comments

1

This is a issue with the version of the MySQL connector packages you are using. In my case, I am using MySQL.Data, MySQL.Entity and MySQL.Web from Nuget. If I use any version after 6.9.11 then I get the behavior you mention.

7 Comments

Your question is probably a duplicate of stackoverflow.com/questions/49036983/…
When i do that everything works fine, but i lost access to Entity framework v6 and its a requirement for this project. In your case you are using v5 or v6 of entity framework?
Nuget tells me: 6.2.0
If you dont mind can you try generate a model from database using that version ?
No problem. My test worked. In the linked answer above there is a bit about removing the default version of "MySQL for Visual Studio" and installing the the latest development version (2.0.5). Basically, I don't think Oracle actually tests the MySQL software it produces.
|
0

-First Step-
using mySql installer : https://dev.mysql.com/downloads/installer/
Download
1 - mySql router
2 - Connector/ODBC
3 - Connector/C++
4 - Connector/Net
5 - MySQl Server
All , exactly in version : 8.0.12

Then go to visual studio > manage nugget packages > browse(tab) (and install)
1 - entityFramework -> version 6
2 - mysql.data -> version 8.0.12
3 - mysql.data.entity -> version 6
4 - mysql.data.entityFramework -> version 8.0.12

Then go to visual studio > manage nugget packages > updates(tab)
update Google.protoBuf to version 3.6.0

-Second Step-
Right click your project > Add new Item > Data (left navbar) > Ado.net Data Model
The Connection dialogue will appear, create a new connection using your Mysql (version 8.0.12) credentials.
(check the input : include the sensitive data in the connectionString ..)

You will get an error ! that because the preconfigured MySqlProviderServices comes with the version 8.0.11 , all you have to do is to change it in the file App.config (next step). the problem is : when you go look the latest version of MySql.Data.Entity is 6.10.7, so this means when download Connector/NET 8 then there is a version incompatibility which results in the ADO.Net data entity wizard closing.

-Third step (final)-
go to your App.config file , and change your "providers" Tag to become like that

<providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <!--<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />-->
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.EntityFramework, Version=8.0.12.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</providers>

Thats's All , now build the project and you're done you can create your Entity Data Model (database first for example..) and map your MySql database and query it on your project
ressources :
https://www.youtube.com/watch?v=xvgeeaVP4M4
https://www.devjockeys.com/blog/c-sharp/using-entity-framework-with-mysql-a-code-first-example/
https://ozanecare.com/connect-mysql-with-visual-studio-2019/
Entity Framework With mysql Database First

2 Comments

What version of VS are you using? I'm able to see the Data Model wizard but it seems to crash and reopen the "Add Item" dialogue
@Daniel this is exactly the problem that I had mentioned, it happens when you have at least one different version of the components , that's why I suggested on having the same versions, verify your app.config file, or try re-installing the correct version of each component . ps : I have Visual Studio 2019 (this works also for visual studio 2017 and 2015 #tested )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.