1. Environment
The compiler vs2019
dotnet core 2.2 runtime
Database Mysql 5.8
2. Development Readiness
Because the network connection is created with the reasons CLI tools abp official of the failure, but fortunately there is a corresponding net abp Chinese domestic CLI tool, thank ~
Installation CLI
dotnet tool install -g Cn.Abp.Cli
If you previously installed, the update can be used:
dotnet tool update -g Cn.Abp.Cli
3. Create a project
According to the official example, create aAcme.BookStore项目
cnabp new Acme.BookStore
VS打开项目后,安装包会自动还原,默认数据库是sqlserver,这时候不要运行,因为我们是要使用mysql数据库的。
创建一个mysql空数据库,数据库名自定。
在Acme.BookStore.Web 项目中的appsettings.json 里面,修改配置字符串为mysql
"ConnectionStrings": { "Default": "Server=localhost;Database=BookStore;Uid=root;Pwd=psd" }
4. Storage switching Mysql
Replace the Acme.BookStore.EntityFrameworkCore.DbMigrations project Nuget package.
In the search for the installation Nuget
Volo.Abp.EntityFrameworkCore.MySQL
Meanwhile uninstall the default
Volo.Abp.EntityFrameworkCore.SqlServer
编译项目,修改出错的地方,将sqlserver相关的内容更换为mysql。可以编译通过后,设置Acme.BookStore.EntityFrameworkCore.DbMigrations 项目为启动项目,将Acme.BookStore.Web 项目中的
appsettings.json加入到项目的应用中(迁移DB的时候会需要使用)
5. 生成数据库
运行命令
Update-Database
Tip error:
Your startup project 'Acme.BookStore.EntityFrameworkCore.DbMigrations' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
Corresponding installation package Nuget:
Microsoft.EntityFrameworkCore.Design
again execute the command
Update-Database
Restore successful Web project running successfully up and running.
Reference connection:
https://github.com/cnAbp/abp-cli
https://cn.abp.io/documents/abp/latest/Getting-Started-AspNetCore-MVC-Template