Skip to content

Latest commit

 

History

History
112 lines (91 loc) · 4.05 KB

cleantemplate.md

File metadata and controls

112 lines (91 loc) · 4.05 KB

How to Initialize and Run a Clean Template

  1. Download ASP.NET Boilerplate template
  2. Fix EFCore Versions & Add DotNet Tooling
  3. Change Database Connection String
  4. Restore NuGet Packages
  5. Create Database
  6. Run Backend
  7. Install NPM Dependencies
  8. Refresh Swagger Proxies
  9. Run Frontend

1. Download template

Goto the ASP.NET Boilerplate website and download the ASP.NET Core 1.x template using the .NET Core 1.1 framework, select Single Page Web Application using Angular 2 and make sure Include module-zero is checked.

2. Fix EFCore Versions & Add DotNet Tooling

This step is specific to ABP 2.0.2 and can be ignored for later versions.

Edit project.EntityFrameworkCore.csproj found in the /aspnet-core/src/project.EntityFrameworkCore directory and update the references to the ones below:

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
  </ItemGroup>

Note there is an extra reference added to enable using the Entity Framework Core CLI. Now add the CLI tool reference:

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
  </ItemGroup>

3. Change Database Connection String

Edit the appsettings.json file in the .Web.Host folder, and update the connection string to change the Data Source to use localdb.

  "ConnectionStrings": {
    "Default": "Data Source=(localdb)\\MSSQLLocalDB; Initial Catalog=PeopleProject;"
  }

Initial Catalog is the name you want to use for the database.

4. Restore NuGet Packages

We will use the .NET Core Shared Framework Host (dotnet) to restore the projects' NuGet packages and run our Entity Framework Core commands.

Open PowerShell, navigate to the /aspnet-core directory and run

dotnet restore

5. Create Database

Still in PowerShell go to the .EntityFrameworkCore directory and run

dotnet ef

If you don't see the unicorn, something has gone wrong. Otherwise run

dotnet ef database update

6. Run Backend

Start Visual Studio 2017 and open the solution. Set the .Web.Host project as the Startup Project and debug the solution.

7. Install NPM Dependencies

In the /angular directory run:

yarn install

Versions before 2.3.0 use NPM instead of Yarn.

npm install

This will take some time while it downloads all the dependencies.

8. Refresh Swagger Proxies

While not technically necessary now navigate to the /angular/nswag directory and run:

refresh.bat

9. Run Frontend

Return to the /angular directory and run:

yarn start

Versions before 2.3.0 use NPM instead of Yarn.

npm start

This will start the frontend as well as the continuous transpiling so that as you edit the typescript and HTML files and save the code is immediately compiled and the application refreshed.

Open a web browser and navigate to the client site:

http://localhost:4200

Congratulations! We're done!

At this point we've downloaded, initialized and run the bare template. Well done on making it this far. Now we can start to create our own customizations on top of the ASP.NET Boilerplate platform.

See Also