1.安装mysql server
下载地址 http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.21-winx64.zip
2.安装MySql的VS插件(版本请下载最新版)
mysql-for-visualstudio-1.2.3.msi
3.安装用于.net连接程序
mysql-connector-net-6.9.6.msi
4.使用Nuget Packages(Nuget 程序包管理器)安装EF
使用命令
Install-Package EntityFramework
Install-Package EntityFramework.zh-hans
5.可选项安装 mySql ef6 支持
Install-Package MySql.Data.Entity
这个东西在安装connector后目录就有。
6.修改app.config
<entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
编辑项目文件:
<Reference Include="MySql.Data, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\MySQL\MySQL Connector Net 6.9.6\Assemblies\v4.5\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="MySql.Data.Entity.EF6, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\MySQL\MySQL Connector Net 6.9.6\Assemblies\v4.5\MySql.Data.Entity.EF6.dll</HintPath>
</Reference>
如果Nuget已获取,可使用Uninstall-Package 卸载原程序包