2

Can someone help me with this problem??. I want use "Reverse Engineering Code First" with entity framework used MySQL. I was installed odbc, connector .net etc but still I cant see this... I did everything in this topic (and I have this same problem): Can't use a MySQL connection for entity framework 6

but still doesnt work :(. I was record all steps what I do it.. (Sry for english): https://youtu.be/xqEgCsu7_eU

Community
  • 1
  • 1
mariusz695
  • 47
  • 6

1 Answers1

0

I've gotten it to work with MySql Connector 6.9.11. Its so darned difficult and fragile I'm not sure if it was ultimately a good idea. There are at least 10 things that can go wrong and suck up hours of time. Once you get it working be very careful to not change anything. Anyhow. Here's some of my notes:

WARNING use with MySQL server 5.6.39 or 5.7.19. Do NOT use MySQL server version 5.7.21 (it fails with reverse eng) Aurora seems ok.

Install "mysql-connector-net-6.9.11.msi". There seems to be a problem with newer MySQL Connector 6.10 ?? use older 6.9.11. MUST INSTALL VIA msi file. Having the local file is not enough.

Install "mysql-for-visualstudio-1.2.8.msi" or "mysql-for-visualstudio-1.2.7.msi" ? NOTE: 1.2.7 will never uninstall correctly. VS 2015 seems to require "MySQL for Visual Studio" for EF Poco to work, (Pro,Enterprise are different)

Must have "Entity Framework Power tools Beta 4" installed as a plugin to Visual Studio 2013. Its takes some effort to get it to install for 2015, 17 but it can be done. https://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d

Things that can go wrong:

ISSUE 1: you get error "One or more errors occurred while processing template 'Entity.tt'." This ALWAYS happens the first time i use reverse engineer after restarting VS. Simply changing the .NET assemmbly version seems to do the trick. Target .NET 4.5 (not 4.5.1) for reverse engineer. use .net4.5 for EF. If you see exception "System.ArgumentException: Empty path name is not legal."
remember to change back to 4.5.2 or greater. VS2015 Edit and Continue is supported for 64-bit projects that target the .NET Framework 4.5.1. (or 4.5.2)

ISSUE 2: System.ArgumentException: The specified store provider 'MySql.Data.MySqlClient' cannot be found in the configuration, or 'MySql.Data.MySqlClient' is not valid. This appears to be an app/web.config issue. ??? MySql.Data.MySqlClient has more than 1 entry in in app.config ?? or bindingRedirect is wrong ?? might be wrong version consistently 6.9.11 ? MySql.Data.MySqlClient ?? Install correct version 6.9.11 in GAC not just nuget ? mysql-connector-net-6.9.11.msi

ISSUE 3: MySQL issue - "error 6003: The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull." Specified cast is not valid. [1 Jan 2016 15:27] "Noman Khan. Run the following command on the MySQL DB and then try if this works. set global optimizer_switch='derived_merge=off'" (on the user you will use. i.e root)

ISSUE 4: Out of memory execption. Restart VisualStudio.

ISSUE 5: If "MySQL" option doesnt display in the "Change Data source" listbox. Install the Visual Studio MySQL Plugin Can't use a MySQL connection for entity framework 6

NOTE: EntityFrameworkPowerToolsBeta4 is not built for VS2015 or 17. The installer version must be modified for it to install How to use Entity Framework Power Tools in Visual Studio 2015? http://thedatafarm.com/data-access/installing-ef-power-tools-into-vs2015/

NOTE: You can view the Generated SQL query by debugging/break on the object prior to deferred execution of the query. You can Use Aliases to map to other db's Watch out for poor pluralization rules like "Statu" to "Status"

Check out https://us.visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838/view/Discussions This seems to be more configurable and better supported. But only works for MSSQL?

Menace
  • 1,061
  • 13
  • 15
  • I have since switched to EF Core and use the Pomelo connector. I get much more stable behavior. https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql – Menace Jan 04 '19 at 15:29