CodingBeagle
CodingBeagle

Reputation: 1950

Attempting to create an Entity Framework model from a MySQL database fails with an unexpected exception

So, I'm trying to get set up my MySQL and ASP.NET.

Currently, I have both Visual Studio 2013 and Visual Studio 2015 installed on my PC. I used this installer for MySQL (Basically one that comes with everything you need to get started, including MySQL For Visual studio): MySQL Installer

Anyways, as a quick test I made a new ASP.NET MVC project, connected to the database in the server browser (which works just fine!). However, I then tried to create an ADO.NET model from it. When I come to the step of generating the model from the database, I get this error/exception:

Error/Exception Message

This happens in both Visual Studio 2013 and Visual Studio 2015.

I have tried to search my way out of this (I've also tried with different databases, I used some of the sample databases included with the MySQL server installed, still got the same error), but I don't seem to be able to find much information on it. Additionally, it might be worth noting that when I select the version of the Entity Framework to use, I get this:

Entity Framework version select

Which seems odd as I'd think the newest MySQL installer did actually include MySQL for Visual Studio which supports EF 6.x?

Anyways, any assistance or hints on this problem will be much appreciated :)

EDIT - Narrowed down the problem a bit

So, I found out that this problem occours whenever I have a database with foreign keys in. Still no clue why, but databases without them I can easily generate!

Upvotes: 1

Views: 841

Answers (2)

user8625842
user8625842

Reputation: 1

If you have many schema inyour database, the Global parameter is not your solution. test with : set session optimizer_switch='derived_merge=off' to impact your schema and not the entire base

Upvotes: 0

flaubert165
flaubert165

Reputation: 11

Try to run this command on MySQL WorkBench:

set global optimizer_switch='derived_merge=off'

Good luck!

Upvotes: 1

Related Questions