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

?





1

2

3

4

5

6

7

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,布布扣,bubuko.com

Using MySQL Connector .NET 6.6.4 with Entity Framework
5

时间: 2024-08-28 18:13:09

Using MySQL Connector .NET 6.6.4 with Entity Framework 5的相关文章

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

报错信息 Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezon

mysql.connector操作mysql的blob值

This tutorial shows you how to work with MySQL BLOB data in Python, with examples of updating and reading BLOB data. The  authors table has a column named  photo whose data type is BLOB. We will read data from a picture file and update to the photo c

Installing MySQL Connector/Python using pip v1.5

The latest pip versions will fail on you when the packages it needs to install are not hosted on PyPI . When you try to install MySQL Connector/Python the usually way, you get following message is: shell> pip install mysql-connector-python Could not

MySQL Connector/Python 开发者指南

本文翻译自:https://dev.mysql.com/doc/connector-python/en/ 摘要 这篇手册描述了怎么来安装和配置 MySQL Connector/Python,MySQL Connector/Python 是 Python 和 MySQL 服务进行通信的一个独立驱动程序,本篇手册还将阐述如何利用它来开发数据库应用程序. 获取 Connector/Python 的每一次发布版本的改动细节,请参阅 MySQL Connector/Python Release Notes

mysql.connector 事务总结

mysql.connector事务总结: connection.autocommit = 0 (默认值) 事务处理 使用 connection.commit()方法 #!/usr/bin/env python # -*- coding:utf-8 -*- '''mysql.connector事务总结: connection.autocommit = 0 (默认值) 事务处理 使用 connection.commit()方法 分析: 智能commit状态: connection.autocommi

Snippet: Fetching results after calling stored procedures using MySQL Connector/Python

https://geert.vanderkelen.org/2014/results-after-procedure-call/ Problem Using MySQL Connector/Python, you are calling a stored procedure which is also selecting data and you would like to fetch the rows of the result. Solution For this example we cr

Visual Studio 2015编译64位MySQL Connector/C++

目前MySQL Connector/C++的binary版本最高只支持VS2008,VS2015需要下载源码自行编译. 尽管MySQL手册提供了信息,但在编译过程中还是有不少细节需要注意. CMAKE 到官网下载最新的稳定版本 把bin目录添加到环境变量PATH中 Boost 同样到官网下载最新的稳定版本 MySQL客户端库 MySQL客户端库头文件在MySQL目录下的include目录中 是的,编译connector还需要下载一个MySQL Server 添加环境变量MYSQL_DIR,值为M

Developing DataBase Applications Using MySQL Connector/C++ 中文文本

Developing DataBase Applications Using MySQL Connector/C++ 中文文本 ? by grayondream 翻译自mysql Connector C++帮助文档[http://download.csdn.net/detail/midle110/4931166] ? 本教程将利用从MySQL数据库中链接,插入和检索数据的简单示例向您展示构建和安装MySQL Connector / C ++驱动程序的基本步骤.因为本文的重点是使用C++ Conn

Ubuntu & MacOS安装Mysql & connector

Ubuntu & MacOS安装Mysql & connector 1. 安装MySql sudo apt-get install mysql-server apt-get install mysql-client sudo apt-get install libmysqlclient-dev 2.安装Mysql.connector # wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1