1 下载一个新的 ABP 模板项目
http://www.aspnetboilerplate.com/
2 在 Windows 上安装 MySql, 创建一个新的数据库 sampledb
https://dev.mysql.com/doc/refman/8.0/en/mysql-installer-gui.html - MySql 的安装文档
https://downloads.mysql.com/archives/installer/ - mysql-installer-gui 的下载地址
3 打开模板项目,在 EntityFramework 和 web 项目中安装 MySql.Data.Entity
Install-Package MySql.Data.Entity -Version 6.8.3 / Install-Package MySql.Data.Entity - 安装 MySql.Data.Entity 组件的命令
注意: 这里不要安装最新版本的 MySql.Data.Entity, 因为模板项目使用的. net framework 版本是 4.5.2, 对应的 MySql.Data.Entity 的版本要使用 6.8.3 , 如果使用最新的版本,后面会报错
4 修改 Web.config 文件
- <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"
- />
- <providers>
- <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"
- />
- <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"
- />
- </providers>
- </entityFramework>
- <connectionStrings>
- <add name="Default" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=sampledb;uid=root;password=*** "
- />
- </connectionStrings>
关于 Ef6 to MySql 可参考文档 http://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html
5 在 Package Manager Console 中执行命令 Update-Database –Verbos
6 现在就可以运行 ABP 的模板项目了
来源: http://www.bubuko.com/infodetail-1869841.html