• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
我思故我在
博客园    首页    新随笔    联系   管理    订阅  订阅

在ABP模板工程中使用MySql

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的模板项目了

 

posted @ 2016-12-12 22:31  lcyhjx  阅读(1250)  评论(4)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3