The ABP framework uses (a) framework generation + MySQL database changes

tags: ABP framework use  c#

1. Create a project

Enter the official website of the ABP framework,http://abp.io/There are two ways to create a framework here, the first is to use the command line, the second is to generate a compressed package directly on the website, this article uses the second method.

1. Click GET STRATED-> select the DIRECT DOWNLOAD method, fill in the project information as follows, after completion, click CREATE NOW to automatically generate an ABP framework compression package

After decompression, use VS2019 to open the solution, the structure directory is shown in the figure, thenSet ABPBookStore.Web as the startup item

2. The database is changed, the database defaults to SQLserver, and now it is replaced with MYSQL.https://dotnet9.com/11978.html

1) Modify the link string in ABPBookStore.Web->appsettings.json, as follows

2) Manage the Nuget package in the "ABPBookStore.EntityFrameworkCore" project, uninstall the "Volo.Abp.EntityFrameworkCore.SqlServer" package,

Browse to install"Volo.Abp.EntityFrameworkCore.MySQL"Package

3) Modify the error prompt

“ABPBookStore.EntityFrameworkCore" project in the ABPBookStoreEntityFrameworkCoreModule.cs fileoptions.UseSQLServer()
is modified to:options.UseMySQL()
will depend on the project"typeof(AbpEntityFrameworkCoreSqlServerModule)"change into"typeof(AbpEntityFrameworkCoreMySQLModule)". Add corresponding references and delete invalid using references.

In the "ABPBookStore.EntityFrameworkCore.DbMigrations" project, in the ABPBookStoreMigrationsDbContextFactory.CS file in the EntityFrameworkCore folder

Change var builder = new DbContextOptionsBuilder<ABPBookStoreMigrationsDbContext>()
                .UseSqlServer(configuration.GetConnectionString("Default"));

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

4) Modify errors in Web items

Delete the Migrator folder under the "ABPBookStore.EntityFrameworkCore.DbMigrations" project and regenerate the solution
 

5) Modification cannot create tableIdentityServerApiSecuritymistake

inABPBookStore.EntityFrameworkCoreproject,"EntityFrameworkCore"Folder, addIdentityServerModelCreatingExtensionsclass. code show as below:

public static class IdentityServerModelCreatingExtensions

{

public static void ConfigureIdentityServerForMySQL(this ModelBuilder builder)

{

// Solve the problem of MySQL migration

// https://github.com/abpframework/abp/issues/1920

builder.Entity<ApiSecret>(b =>

{

// After trying, you can also set it to 400

b.Property(x => x.Value).HasMaxLength(300);

});

builder.Entity<ClientPostLogoutRedirectUri>(b =>

{

b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300); // or 400 ?

});

builder.Entity<ClientRedirectUri>(b =>

{

b.Property(x => x.RedirectUri).HasMaxLength(300); // or 400 ?

});

builder.Entity<ClientSecret>(b =>

{

b.Property(x => x.Value).HasMaxLength(300); // or 400 ?

});

}

}

inABPBookStoreDbContextIn classOnModelCreatingAt the end of the method, add the following code and add the corresponding using reference:

builder.ConfigureIdentityServer(options =>

{

options.DatabaseProvider = EfCoreDatabaseProvider.MySql;

});

builder.ConfigureIdentityServerForMySQL();

inABPBookStoreDbContextModelCreatingExtensionsIn the fileConfigureABPBookStoreAdd the following code under the method:

builder.ConfigureIdentityServer(options =>

{

options.DatabaseProvider = EfCoreDatabaseProvider.MySql;

});

6) Regenerate the migration

Regenerate the solution, set the ABPBookStore.Web project as the startup project, select Tools -> NuGet Package Management -> Package Management Console, set the default project to "ABPBookStore.EntityFrameworkCore.DbMigrations", enteradd-migrationCommand to regenerate the migration.

 

After the migration is complete, enter update-database to update the database

The project can run

 

 

 

 

Intelligent Recommendation

Django introduces integration with the framework, and uses MySQL to implement additions, deletions, and changes.

Introduction to Django Django is an open source Python web application framework. The MTV mode is used, namely model M, template T and view V. He was originally developed to manage some news content-b...

The method of using Mysql database in Abp framework as well as issues related to small mind

Recently I discovered a framework of DDD   Looks good, it is said very abuses of   Just recently to get some small things, try to bring good   Forced to suffer poor can not afford high ...

ABP framework - boot configuration

ABP can configure the module at boot time. Configuration ABP In the method PreInitialize module can be configured to ABP. Configuration example: ABP is a modular design, different modules can be confi...

ABP Framework - Introduction

In 14, 15 years, he led several different teams, delivered several projects, in the process, although several items of business are not the same, but a lot of the basic architecture of the application...

ABP framework learning

Transferred from ABP framework learning   1. Overall and public structure   1. ABP configuration   2. Multi-tenancy   3,ABP Session   4. Cache    5, the log   6. Setting management    7...

More Recommendation

ABP framework introduces easyUI

(1) First download easyUI official website:http://www.jeasyui.com/download/list.php (2) Create the easyUI-1.9 folder in the wwwroot \ lib folder of the Web.Mvc layer, and then copy the contents of the...

ABP framework construction process

1. Use the official template to create a solution (project) 1. Download the solution code Open the official website: https://aspnetboilerplate.com/Templates Click the menu download, as follows Select ...

ABP framework application

ABP framework application Reference materials: https://www.cnblogs.com/farb/p/ABPTheory.html To understanding: Use tool: vs2017 Development goal: webapi Use Mysql database API login:*.Core >> Au...

ABP framework-write a WebAPI

  First download a template from ABP official website Which template can be selected in ASP.NET Core Since webapi is not used, it is only done in the background, so the choice of template has no ...

ABP framework learning-AutoMapper.

There are many articles on the study of abp framework on the Internet. Most of this article is also taken from articles by other authors. Official api document:https://aspnetboilerplate.com/api-docs/h...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top