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. jQuery1.11源码分析(1)-----Sizzle源码概览[原创]

    最近在啃jQuery1.11源码,上来就遇到Sizzle这个jQuery的大核心,虽然已经清楚了Sizzle的用途,先绕过去也没事,但明知山有虎偏向虎山行才是我们要做的. 本文面向的阅读对象:正在学习 ...

  2. sqilite学习

    1,用代码插入数据 for (int i = 0; i < 100; i++) {        NSString *nameStr = [NSString stringWithFormat:@ ...

  3. [Hadoop] 在Ubuntu系统上一步步搭建Hadoop(单机模式)

    1 Hadoop的三种创建模式 单机模式操作是Hadoop的默认操作模式,当首次解压Hadoop的源码包时,Hadoop无法了解硬件安装环境,会保守地选择最小配置,即单机模式.该模式主要用于开发调试M ...

  4. HTTP请求报文格式

    HTTP报文是面向文本的,报文中的每一个字段都是一些ASCII码串,各个字段的长度是不确定的.HTTP有两类报文:请求报文和响应报文. 请求报文 一个HTTP请求报文由请求行(request line ...

  5. Python转码问题的解决方法:UnicodeDecodeError:‘gbk' codec can't decode bytes in position

    在开发过程中遇到了错误:UnicodeDecodeError: ‘gbk' codec can't decode bytes in position 678-679...这是因为遇到了非法字符, 解决 ...

  6. UVa2521

    理解:max 记录的是有大牌的个数 mid 是有中断 而造成的不确定  我理解是一个间断点以下的 数和一个间断点抵消 在前面没有间断的情况下 才能确定这张牌稳赢 #include<iostrea ...

  7. edghasdz

    匹配2016年10月8日19时51分50秒匹配 可以使用

  8. java10

    1:正则表达式(理解) (1)就是符合一定规则的字符串 (2)常见规则 A:字符 x 字符 x.举例:'a'表示字符a \\ 反斜线字符. \n 新行(换行)符 ('\u000A') \r 回车符 ( ...

  9. 此地址使用了一个通常用于网络浏览以外的端口。出于安全原因,Firefox 取消了该请求

    FirFox打开80以外的端口,会弹出以下提示: “此地址使用了一个通常用于网络浏览以外的端口.出于安全原因,Firefox 取消了该请求.”. 解决方法如下: 在Firefox地址栏输入about: ...

  10. sql 删除表中某字段的重复数据

    重复字段:BarCode SELECT * FROM dbo.AssetBarCode WHERE BarCode IN (SELECT BarCode FROM dbo.AssetBarCode G ...