0%

abp新建项目指南

替换数据库为mysql

  1. 替换mysql,Dothass.Blog.EntityFrameworkCore项目中
1
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="2.8.0" />
  1. 删除之前的迁移目录

  2. 修改连接字符串 项目Dothass.Blog.DbMigratorDothass.Blog.Web..

    1
    2
    3
    4
    //详情请见https://www.connectionstrings.com/mysql/
    "ConnectionStrings": {
    "Default": server=localhost;port=3306;database=dothass.blog;uid=root;password=123456"
    },
  3. 生成新的迁移,nuget包管理器.默认项目设置为Dothass.Blog.EntityFrameworkCore.DbMigrations

1
Add-Migration Init

相关链接: https://docs.abp.io/zh-Hans/abp/latest/Entity-Framework-Core-MySQL

初始化项目

  1. 将三个项目copy到程序中.然后在web项目中添加依赖typeof(AbpExtensionWebModule)即可
  2. 修改migrationservice,DotHass.Blog.Domain项目下BlogDbMigrationService
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    private async Task SeedDataAsync(Tenant tenant = null)
    {
    Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");

    //IdentityDataSeedContributor : IDataSeedContributor ---> IIdentityDataSeeder
    //手动实例化上下文,来设置admin的email和密码..或者替换IIdentityDataSeeder的service
    var seedContext = new DataSeedContext(tenant?.Id);
    var configurationSection = _configuration.GetSection("Identity");
    seedContext.WithProperty("AdminEmail", configurationSection["AdminEmail"]);
    seedContext.WithProperty("AdminPassword", configurationSection["AdminPassword"]);

    //PermissionDataSeedContributor : IDataSeedContributor --->IPermissionDataSeeder
    //为amidn添加权限 -- 一般来说不用改什么,但是需要在BlogDbMigratorModule中引用你设置权限的模块依赖..否则找不到你添加的权限

    await _dataSeeder.SeedAsync(seedContext);
    }
  3. 执行项目Dothass.Blog.DbMigrator初始化数据

关于客户端js

执行 yarn & gulp 将所有包都会将自己的资源复制到wwwroot/libs文件夹中. 否则一些模块例如博客的js时不会起作用的