ABP study note 2

Download the official framework, using the EF Core.

Use application migration, reverse generated database, configure database connection address good appsettings.json file.

According to the database you want to configure the connection address.

For example, you want to use sql server, then you configure the connection string sql server database.

You have to use the Oracle database, then you configure the Oracle database connection string.

Generating a reverse, it will automatically recognize the address, thereby generating a corresponding database.

 

If you run xxx.Web project, reported the other end of the pipe without any process, please review the items below appsettings.json file

Database Connection address is correct.

 

Domain layer starting template is divided into two items:

  • xxx.BookStore.DomainInclude your entity , field service and other core domain objects.
  • xxx.BookStore.Domain.SharedIt contains constants, enumsor other related fields of objects can be shared with end customers.

EF Core requires an entity associated with your DbContext . The easiest way is to place a DbSetproperty is added to xxx.BookStore.EntityFrameworkCore project in the BookStoreDbContextclass.

In xxx.BookStore.EntityFrameworkCorethe project opened BookStoreDbContextModelCreatingExtensions.cs file and add the following code to the ConfigureBookStoremethod of the end to configure the Book entity:

builder.Entity<Book>(b =>
{
    b.ToTable(BookStoreConsts.DbTablePrefix + "Books", BookStoreConsts.DbSchema);
    b.ConfigureByConvention(); //auto configure for the base class props
    b.Property(x => x.Name).IsRequired().HasMaxLength(128);
});
 b.Property (x => x.Name) .IsRequired () HasMaxLength (128);. is the maximum length of the Name property of the requesting entity.

Add the using Volo.Abp.EntityFrameworkCore.Modeling;statement to address the ConfigureByConventionextension method.

 

After completion of the association, open NuGet VS console, set xxx .BookStore.EntityFrameworkCore.DbMigrationsas the default startup project and execute the following command:

Add-Migration "Created_Book_Entity"

This will be the xxx.BookStore.EntityFrameworkCore.DbMigrationsproject 's Migrations folder to create a new category within the migration .

 

 

Then execute the Update-Databasecommand to update the database schema:

When performing the migration, pay attention to whether they contain the following items appsettings.json documents inside the database connection string in order to restore to the library, and if not, then just go to the configured copy over appsettings.json project.

 

The application layer is divided into two items:

  • xxx.BookStore.Application.ContractsInclude your main DTOand application services interfaces.
  • xxx.BookStore.Application It contains your application service implementation.

DTO class for data transmission of the presentation layer and the data layer.

You need to be mapped after addition. Plus go after the expiry of the interface mapping.

After finished interface map, ABP frame automatically generated into a corresponding API interface.

After an interface, xxx.Web layer to create pages, to make the call interface for data transmission.

Specific steps, please refer to the official tutorial. (Official website tutorial on a)

Guess you like

Origin www.cnblogs.com/fengbenwuxing/p/12660044.html