惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - Franky
IT之家
IT之家
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
腾讯CDC
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
博客园_首页
G
Google Developers Blog

博客园 - HUGO.CM

安装OpenCode后,无法使用。解决方案 修改Abp中Auto API Controllers中 默认生成的 Put、Delete请求 vs2022 开发Python 中文报错:SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte Abp9.0.4运行DbMigrator,报错“The LINQ expression '@__organizationUnitIds_0' could not be translated. ...” 执行abp命令时,出现死循环解决方案 ABP与BootstrapBlazor 本地化相关处理 【机译】ABP Helper Methods Blazor文件上传异常:Did not receive any data in the allotted time Abp报错:AbpException: No theme registered! Use AbpThemingOptions to register themes. Abp分布式实体缓存 Abp vNext 在控制台输出SQL 【译】在 ABP 框架项目中配置多个数据库上下文 ABP浏览页面报错:Could not find the bundle file '/libs/abp/core/abp.css' for the bundle 'LeptonXLite.Global' 或 'Basic.Global' 运行abp install-libs再报错npm ERR! code E404 Abp配置文件设置IdentityServer客户端 精简版Abp开发教程 - 第三章: 创建应用程序 精简版Abp开发教程 - 第二章: 创建实体与数据库 精简版Abp开发教程 - 第一章: 创建解决方案 Abp vNext 修改默认表前缀 Abp vNext 使用sql2005、sql2008等脚本报错解决
Abp vNext 使用Mysql数据库
HUGO.CM · 2020-06-17 · via 博客园 - HUGO.CM

1.项目 EntityFrameworkCore 添加引用 Volo.Abp.EntityFrameworkCore.MySQL。

2.在 EntityFrameworkCoreModule.cs 中代码 typeof(AbpEntityFrameworkCoreSqlServerModule) 修改为 typeof(AbpEntityFrameworkCoreMySQLModule) 。

[DependsOn(
        typeof(MyProjectDomainModule),
        typeof(AbpIdentityEntityFrameworkCoreModule),
        typeof(AbpIdentityServerEntityFrameworkCoreModule),
        typeof(AbpPermissionManagementEntityFrameworkCoreModule),
        typeof(AbpSettingManagementEntityFrameworkCoreModule),
        typeof(AbpEntityFrameworkCoreMySQLModule),
        typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
        typeof(AbpAuditLoggingEntityFrameworkCoreModule),
        typeof(AbpTenantManagementEntityFrameworkCoreModule),
        typeof(AbpFeatureManagementEntityFrameworkCoreModule)
        )]

3.在 EntityFrameworkCoreModule.cs 中 修改 options.UseSqlServer() 为 options.UseMySQL()。

public override void ConfigureServices(ServiceConfigurationContext context)
{
    context.Services.AddAbpDbContext<MyProjectDbContext>(options =>
    {
        /* Remove "includeAllEntities: true" to create
         * default repositories only for aggregate roots */
        options.AddDefaultRepositories(includeAllEntities: true);
    });

    Configure<AbpDbContextOptions>(options =>
    {
        /* The main point to change your DBMS.
         * See also MyProjectMigrationsDbContextFactory for EF Core tooling. */
        options.UseMySQL();
    });
}

4.在 DbContextModelCreatingExtensions.cs 中 ConfigureMyProject 方法 添加 builder.UseMySQL();  代码。 

public static void ConfigureMyProject(this ModelBuilder builder)
{
    Check.NotNull(builder, nameof(builder));

    /* Configure your own tables/entities inside here */

    //builder.Entity<YourEntity>(b =>
    //{
    //    b.ToTable(MyProjectConsts.DbTablePrefix + "YourEntities", MyProjectConsts.DbSchema);

    //    //...
    //});

    builder.UseMySQL();
}

5. 项目 EntityFrameworkCore.DbMigrations 中 MigrationsDbContextFactory.cs  修改 .UseSqlServer 为 .UseMySQL。

public MyProjectMigrationsDbContext CreateDbContext(string[] args)
{
    MyProjectEfCoreEntityExtensionMappings.Configure();

    var configuration = BuildConfiguration();

    var builder = new DbContextOptionsBuilder<MyProjectMigrationsDbContext>()
        .UseMySql(configuration.GetConnectionString("Default"));

    return new MyProjectMigrationsDbContext(builder.Options);
}
UseMySql