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

时间:2015-10-30 23:01:03

标签: mysql asp.net database entity-framework visual-studio

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!

2 个答案:

答案 0 :(得分:1)

尝试在MySQL WorkBench上运行此命令:

set global optimizer_switch='derived_merge=off'
祝你好运!

答案 1 :(得分:0)

如果您的数据库中有许多架构,则Global参数不是您的解决方案。 test with:set session optimizer_switch ='derived_merge = off'来影响你的架构而不是整个基础

相关问题