Updated Getting-Started-AspNetCore-MVC-Template document based on the new template structure.

pull/1192/head
Halil İbrahim Kalkan 6 years ago
parent 9b1f4f07df
commit 03ba3563ec

@ -2,39 +2,44 @@
This tutorials explains how to create a new ASP.NET Core MVC web application using the startup template, configure and run it.
### Creating a new project
### Creating a New Project
Go to [the template creation page](https://abp.io/Templates), enter a project name and create your project as shown below:
This tutorial uses **ABP CLI** to create a new project. See the [Get Started](https://abp.io/get-started) page for other options.
![bookstore-create--template](images/bookstore-create-template.png)
Install the ABP CLI using a command line window, if you've not installed before:
When you click the *create* button, a new Visual Studio solution is created and downloaded with the name you have provided.
````bash
dotnet tool install -g Volo.Abp.Cli
````
#### Pre Requirements
Use `abp new` command in an empty folder to create your project:
The downloaded project requires;
````
abp new Acme.BookStore
````
* [Visual Studio 2017 (v15.7.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.1.1+](https://www.microsoft.com/net/download/dotnet-core/)
> You can use different level of namespaces; e.g. BookStore, Acme.BookStore or Acme.Retail.BookStore.
### The Solution Structure
`new` command creates a **layered MVC application** with **Entity Framework Core** as the database provider. However, it has additional options. See the [CLI documentation](CLI.md) for all available options.
Extract the zip file downloaded and open in **Visual Studio 2017 (15.9.0+)**:
#### Pre Requirements
![bookstore-visual-studio-solution](images/bookstore-visual-studio-solution-v2.png)
The created solution requires;
The solution has a layered structure (based on Domain Driven Design) where;
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* ``.Domain`` is the domain layer.
* ``.Application`` is the application layer.
* ``.Web`` is the presentation layer.
* ``.EntityFrameworkCore`` is the EF Core integration package.
### The Solution Structure
Open the solution in **Visual Studio**:
![bookstore-visual-studio-solution](images/bookstore-visual-studio-solution-v3.png)
EF Core database migrations are separated to a project named `.EntityFrameworkCore.DbMigrations`.
The solution has a layered structure (based on [Domain Driven Design](Domain-Driven-Design.md)) and contains unit & integration test projects properly configured to work with **EF Core** & **SQLite in-memory** database.
The solution also contains unit & integration test projects properly configured to work with **EF Core** & **SQLite in-memory** database.
> See [MVC application template document](Startup-Templates/Mvc.md) to understand the solution structure in details.
### Creating the Database
### Database Connection String
Check the **connection string** in the `appsettings.json` file under the `.Web` project:
@ -46,9 +51,29 @@ Check the **connection string** in the `appsettings.json` file under the `.Web`
}
````
The solution is configured to use **Entity Framework Core** with **MS SQL Server**. EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers, so you can use another DBMS if you want.
The solution is configured to use **Entity Framework Core** with **MS SQL Server**. EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers, so you can use another DBMS if you want. Change the connection string if you need.
### Create Database & Apply Database Migrations
You have two options to create the database.
Right click to the `.Web` project and select **Set as StartUp Project**:
#### Using the DbMigrator Application
The solution contains a console application (named `Acme.BookStore.DbMigrator` in this sample) that can create database, apply migrations and seed initial data. It is useful on development as well as on production environment.
> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one.
Right click to the `.DbMigrator` project and select **Set as StartUp Project**:
![set-as-startup-project](images/set-as-startup-project.png)
Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below:
![set-as-startup-project](images/db-migrator-app.png)
#### Using EF Core Update-Database Command
Ef Core has `Update-Database` command which creates database if necessary and applies pending migrations. Right click to the `.Web` project and select **Set as StartUp Project**:
![set-as-startup-project](images/set-as-startup-project.png)
@ -58,17 +83,19 @@ Open the **Package Manager Console**, select `.EntityFrameworkCore.DbMigrations`
This will create a new database based on the configured connection string.
> Using the `.Migrator` tool is the suggested way, because it also seeds the initial data to be able to properly run the web application.
### Running the Application
You can now run the application which will open the **home** page:
Ensure that the `.Web` project is the startup project. Run the application which will open the **home** page in your browser:
![bookstore-homepage](images/bookstore-homepage.png)
Click the **Login** button, enter `admin` as the username and `1q2w3E*` as the password to login to the application.
The startup template includes the **identity management** module. Once you login, the Identity management menu will be available where you can manage **roles**, **users** and their **permissions**.
The startup template includes the **identity management** and **tenant management** modules. Once you login, the Administration menu will be available where you can manage **tenants**, **roles**, **users** and their **permissions**. User management page is shown below:
![bookstore-user-management](images/bookstore-user-management.png)
![bookstore-user-management](images/bookstore-user-management-v2.png)
### What's Next?

@ -20,7 +20,7 @@ Go to the [startup template page](https://abp.io/Templates) and download a new p
This is the how the layered solution structure looks after it's created from the startup template:
![bookstore-visual-studio-solution](images/bookstore-visual-studio-solution-v2.png)
![bookstore-visual-studio-solution](images/bookstore-visual-studio-solution-v3.png)
### Create the Book Entity

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Loading…
Cancel
Save