Using MySQL Connector .NET 6.6.4 with Entity Framework 5
I had been waiting for the latest MySQL connector for .NET to come out so I can move on to the new and sleek Visual Studio 2012 for my projects. Found out connector 6.6.4 has been out which can work with VS2012 so I happily install it. I start a brand new project and start setting up the Membership and Roles using the MySQL Website Configuration tool and everything worked great. To give you some more additional info about the project setup it is targeting .NET Framework 4 and the type of project is a MVC 3 web application using Razor.
Now it was time to let the code first magic happen. I create my models and then issue an Enable-Migration via the package manager console. The migrations are setup. Next I issue the Add-Migration Initial to create the initial scaffolding for my model and I get the following error:
No MigrationSqlGenerator found for provider ‘MySql.Data.MySqlClient’. Use the SetSqlGenerator method in the target migrations configuration class to register additional SQL generators.
Upon doing some research I find out that for the connector version 6.6.4, we’ll have to explicitly set up the SQL code generator. Open Configuration.cs file found in the Migrations folder and add the following line to the constructor
publicConfiguration()
{
AutomaticMigrationsEnabled=false; // register mysql code generator
SetSqlGenerator("MySql.Data.MySqlClient",newMySql.Data.Entity.MySqlMigrationSqlGenerator());
}
After doing that I re-run my Add-Migation Initial command and the scaffolding is generated without any issues this time.
It is time to create the schema and tables. I issue Update-Database -Verbose command now and stumble upon another issue this time which is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.IO.FileLoadException: Could not load file or assembly ‘EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0×80131040)
Upon more research I find out that connector 6.6.4 will not work with Entity Framework 5 but with Entity Framework 4.3. So to downgrade issue the following commands in the package manager console:
1
2
3
|
Uninstall-PackageEntityFramework
Install-PackageEntityFramework-Version4.3.1
|
Finally I do Update-Database -Verbose again and voila! The schema and tables are created. Wait for the next version of connector to use it with Entity Framework 5.
Using MySQL Connector .NET 6.6.4 with Entity Framework 5的更多相关文章
- Entity Framework 学习系列(3) - MySql Code First 开发方式+数据迁移
目录 # 写在前面 一.开发环境 二.创建项目 三.安装程序包 四.创建模型 五.连接字符串 六.编辑程序 七.数据迁移 写在最后 # 写在前面 这几天,一直都在学习Entity Framework ...
- 创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL
创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL 用惯.NET的研发人员都习惯性地使用SQLServer作为数据库.然而.NET Core ...
- vc++2013中使用MySQL connector/C++ 1.1.4静态链接报错
包含头文件 #include <mysql_connection.h> #include <mysql_driver.h> #include <cppconn/state ...
- [转]MySQL Connector/C++(一)
http://www.cnblogs.com/dvwei/archive/2013/04/18/3029464.html#undefined#undefined MySQL Connector/C++ ...
- mysql.connector操作mysql的blob值
This tutorial shows you how to work with MySQL BLOB data in Python, with examples of updating and re ...
- Ubuntu & MacOS安装Mysql & connector
Ubuntu & MacOS安装Mysql & connector 1. 安装MySql sudo apt-get install mysql-server apt-get insta ...
- Snippet: Fetching results after calling stored procedures using MySQL Connector/Python
https://geert.vanderkelen.org/2014/results-after-procedure-call/ Problem Using MySQL Connector/Pytho ...
- MySQL Connector/J 6.x jdbc.properties 配置, mysql-connector-java-6.0.4.jar 异常
今天学习SSM框架整合,完成Spring和mybatis这两大框架的整合做测试时候出来很多问题,主要来自于配置文件. 我这里重点说一下Mysql数据驱动配置. 配置pom.xml时候去网站 MySQL ...
- mybatis/callablestatement调用存储过程mysql connector产生不必要的元数据查询
INFO | jvm 1 | 2016/08/25 15:17:01 | 16-08-25 15:17:01 DEBUG pool-1-thread-371dao.ITaskDao.callProce ...
随机推荐
- 为什么为 const 变量重新赋值不是个静态错误
const 和 let 的唯一区别就是用 const 声明的变量不能被重新赋值(只读变量),比如像下面这样就会报错: const foo = 1 foo = 2 // TypeError: Assig ...
- 扼杀 304,Cache-Control: immutable
随着近些年社交网站的流行,越来越多的人学会了“刷”网页 ── 刷微博,刷朋友圈,刷新闻,刷秒杀页.这里的“刷”,就是刷新的意思,在浏览器里,你可以通过点击刷新按钮,或者用快捷键,或者移动端的下拉操作来 ...
- JSP脚本中的9个内置对象
JSP脚本中包含9个内置对象,这9个内置对象都是Servlet API接口的实例,只是JSP规范对它们进行了默认初始化.也就是说它们已经是对象,可以直接使用. 我们随意打开一个由JSP页面生成的Ser ...
- iphone如何导出微信聊天记录到电脑?
有个小美眉买了个iphone,但发现自己就是一小白,很多功能都不会用,微信倒是用得挺上手的,可以晚上聊到三四点,流量直接飙升500MB.最近她说手机太卡了,问ytkah帮她整一下.拿起她的IPhone ...
- 关于当传过来的值转换成string类型报错的问题
有时候直接写 string str=request.param["str"].tostring;会报错,是因为接受到的值可能是空的 这个时候就可以这样写 string _actio ...
- Daily Scrum Meeting ——FirstDay
一.Daily Scrum Meeting照片 二.Burndown Chart 三.项目进展 1.介绍在github上发布的issues 根据MVC三层模型,我们主要发布的是V层以及M层,C层将根据 ...
- JQ图片轮播
<script src="{staticurl action="jquery.js" type="js"}"></scri ...
- Json序列化与反序列化
参考:http://www.cnblogs.com/caofangsheng/p/5687994.html#commentform 下载链接:http://download.csdn.net/deta ...
- 一个简单的servlet的demo
javaweb 的应用我们需要参考javaee api 查找servlet接口 javax.servletInterface Servlet All Known Subinterfaces: Ht ...
- Ubuntu设置环境变量 16.04
打开终端并输入: sudo gedit /etc/environment. 2 输入用户密码.这时输入的密码是不可见的. 3 如图,在PATH="...."的末尾处添加: :/op ...