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的更多相关文章

  1. Entity Framework 学习系列(3) - MySql Code First 开发方式+数据迁移

    目录 # 写在前面 一.开发环境 二.创建项目 三.安装程序包 四.创建模型 五.连接字符串 六.编辑程序 七.数据迁移 写在最后 # 写在前面 这几天,一直都在学习Entity Framework ...

  2. 创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL

    创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL 用惯.NET的研发人员都习惯性地使用SQLServer作为数据库.然而.NET Core ...

  3. vc++2013中使用MySQL connector/C++ 1.1.4静态链接报错

    包含头文件 #include <mysql_connection.h> #include <mysql_driver.h> #include <cppconn/state ...

  4. [转]MySQL Connector/C++(一)

    http://www.cnblogs.com/dvwei/archive/2013/04/18/3029464.html#undefined#undefined MySQL Connector/C++ ...

  5. mysql.connector操作mysql的blob值

    This tutorial shows you how to work with MySQL BLOB data in Python, with examples of updating and re ...

  6. Ubuntu & MacOS安装Mysql & connector

    Ubuntu & MacOS安装Mysql & connector 1. 安装MySql sudo apt-get install mysql-server apt-get insta ...

  7. 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 ...

  8. MySQL Connector/J 6.x jdbc.properties 配置, mysql-connector-java-6.0.4.jar 异常

    今天学习SSM框架整合,完成Spring和mybatis这两大框架的整合做测试时候出来很多问题,主要来自于配置文件. 我这里重点说一下Mysql数据驱动配置. 配置pom.xml时候去网站 MySQL ...

  9. 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 ...

随机推荐

  1. 图解JVM的类加载机制(详细版)

    注:本文为作者整理和原创,如有转载,请注明出处. 上一篇博文,把JAVA中的Class文件格式用图形的方式画了一下,逻辑感觉清晰多了,同时,也为以后查阅的方便. Class文件只是一种静态格式的二进制 ...

  2. C# 的tcp Socket设置自定义超时时间

    简单的c# TCP通讯(TcpListener) C# 的TCP Socket (同步方式) C# 的TCP Socket (异步方式) C# 的tcp Socket设置自定义超时时间 C# TCP ...

  3. android权限大全

    访问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES ,读取或写入登记check-in数据库属性表的权限 获取错略位置 android.permiss ...

  4. 诸城模拟赛 dvd的逆序对

    [题目描述] dvd是一个爱序列的孩子. 他对序列的热爱以至于他每天都在和序列度过 但是有一个问题他却一直没能解决 给你n,k求1~n有多少排列有恰好k个逆序对 [输入格式] 一行两个整数n,k [输 ...

  5. 【Python网络爬虫一】爬虫原理和URL基本构成

    1.爬虫定义 网络爬虫,即Web Spider,是一个很形象的名字.把互联网比喻成一个蜘蛛网,那么Spider就是在网上爬来爬去的蜘蛛.网络蜘蛛是通过网页的链接地址来寻找网页的.从网站某一个页面(通常 ...

  6. CentOS防火墙iptables的配置方法详解

    CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Linux ...

  7. 【MySQL】使用Length和Cast函数计算TEXT类型字段的长度

    背景: 前段时间,业务需要,为了快速让解析的Excel入库,所以把不是很确定的字段全部设置成了TEXT. 今天需要进行表结构优化,把字段长度控制在合适的范围,并尽量不使用TEXT类型. -- 计算长度 ...

  8. espcms内容页上下篇按后台手动排序号

    模板文件: {%get name=plist class="did":$read.did,pid:$read.pid%} <li class="fl"&g ...

  9. struts2 拦截器

    拦截器:对Action的访问.可以拦截到Action中某个方法.与过滤器不同,过滤器过滤的是请求.过滤JSP.html.但是拦截器不能拦截jsp.html的访问. Struts2 拦截器在访问某个 A ...

  10. CentOS7 开机调整亮度

    默认亮度是100,受不了,所与就自己想了个办法,依赖其它的自启动服务使我的设置生效. /usr/lib/systemd/scripts/nfs-utils_env.sh这是一个开机自启动服务要用到的脚 ...