问题描述
我们正在使用MySql和Entity FrameWork与VS 2013这些工具已安装:
- MySql Server 5.7.8
- MySql WorkBench 6.3。
- Visual Studio 1.2.4的MySql
- 连接器/ NET 6.9。
- VS 2013 Ultimate
- 通过NuGet安装实体FrameWork 6.1.3
我们已经将必需的库导入MySQLWeb,MySQL.Data,Mysql.Data.Emtity.EF6项目中。
我们使用这样一个简单的表创建了一个包含MySQLWorkBench的模式:
CREATE TABLE`persona`(
`idpersona` int(11)NOT NULL,
` nombre` int(11)DEFAULT NULL,
PRIMARY KEY(`idpersona`)
)ENGINE = InnoDB DEFAULT CHARSET = utf8;
我们遇到的问题是,我们创建了我们连接到的ADO.net实体数据模型数据库,但是它不会创建模型并显示以下错误:
我们已经证明,如果我们将所有单列列为主键一切正常,当一列不是主键时,会发生问题,列的类型无关。
我没有找到任何人
非常感谢您阅读我的问题
敬意
实体框架(6.1.3)和MySQL服务器(5.7)
解决问题是,
- 打开服务(services.msc)并重新启动MySQL57服务。
-
在MySQL中执行以下命令。
使用<<数据库名称>>
设置全局optimizer_switch ='derived_merge = OFF'; -
更新.edmx。
li>
We are using MySql and Entity FrameWork with VS 2013 those are the tools installed:
- MySql Server 5.7.8
- MySql WorkBench 6.3.
- MySql for Visual Studio 1.2.4
- Connector/NET 6.9.
- VS 2013 Ultimate
- Entity FrameWork 6.1.3 installed via NuGet
We have imported the necesary libraries into the project MySQLWeb, MySQL.Data, Mysql.Data.Emtity.EF6
We created a schema with MySQLWorkBench with a simple table like this:
CREATE TABLE `persona` (
`idpersona` int(11) NOT NULL,
`nombre` int(11) DEFAULT NULL,
PRIMARY KEY (`idpersona`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
The problem we have is that wuen we create the ADO.net Entity Data Model we connect right to the database but then it not creates the model and show the following error:
We have proved that if we make all single columns as Primary Key everything works fine, the problem happens when one column is not Primary Key it does not matter the type of the column.
I didn´t find anyone with same problem on internet.
Thank you very much for reading my question
regards
Entity Framework (version 6.1.3) and MySQL Server (5.7)
One way to resolve the issue is,
- Open Services (services.msc) and restart MySQL57 service.
Execute the following commands in MySQL.
use <<database name>> set global optimizer_switch='derived_merge=OFF';
Update the .edmx.
这篇关于EF6 MySQL StrongTypingException当列不是PK时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!