Getting Started Series -ASP.NET Core MVC template

Create a new project

This tutorial uses  ABP CLI  to create a new project. For more options, see Getting Started page.

If you have not previously installed, use the command line to install ABP CLI:

dotnet tool install -g Volo.Abp.Cli

Use an empty folder  abp new to create a project command:

abp new Acme.BookStore

You can use different levels of the namespace; for example BookStore, Acme.BookStore or Acme.Retail.BookStore.

new Command creates a hierarchical MVC applicationthe Entity Framework Core as a database provider, but it also has other options. For all available options, see CLI documentation

Prior request

Create project requirements:

Solution structure

In Visual Studio Open the solution:

bookstore-visual-studio-solution

This solution has a layered structure (based on the Domain Driven Design & integrated test items, can), and comprising a unit configured with EF Core and SQLite used with database memory.

See Application template document to learn more about the solution structure.

Database connection string

Check .Webunder the project appsettings.jsonfile in  the connection string:

{
  "ConnectionStrings": {
    "Default": "Server=localhost;Database=BookStore;Trusted_Connection=True"
  }
}

Solutions using  Entity Framework Core  and  MS SQL Server . EF Core supports a variety of database provider, so you can, if necessary, change the connection string according to the actual need to use other DBMS.

Create a database application and database migration

You have two options to create the database.

Use DbMigrator application

The solution includes a console application (called in this example Acme.BookStore.DbMigrator), you can create a database, application migration and initialization data. It is very useful in the development and production environments.

.DbMigratorProject has its own appsettings.json, so if you change the connection string above, you should also change this string.

Right-click the .DbMigratorproject and select  Set as StartUp Project:

set-as-startup-project

Press F5 (or Ctrl + F5) having an output which will run the application as shown below:

set-as-startup-project

Use EF Core Update-Database command

Ef Core has a Update-Databasecommand, you can create a database and application migration needed to hang a right click. .WebProject and select Set as StartUp Project:

set-as-startup-project

Open the Package Manager Console (Package Penalty for Manager Console) , select the .EntityFrameworkCore.DbMigrationsitem as the default project and run the Update-Databasecommand:

pcm-update-database

This will create a new database based on the connection string configuration.

Use .Migratortools is the recommended method because it can initialize the initial data can run Web applications correctly.

Run the application

You can now run the application, it will open the home page:

bookstore-homepage

Click the  Login  button and enter your user name admin, password 1q2w3E*, login application.

Start templates include identity management and tenant management module After login, the "Management" menu, you can manage. Tenants , roles , user and permissions User Management page as follows:

bookstore-user-management

Published 87 original articles · won praise 69 · Views 600,000 +

Guess you like

Origin blog.csdn.net/S2T11Enterprise/article/details/103983660