MyShop, a sample project that can help you getting start with ASP.NET Core easier
Getting started
You will need to have .NET Core 3.0 SDK installed. You can use Visual Studio 2019 or Visual Studio Code
For Visual Studio
-
Open the MyShop.sln, build the solution. Set the MyShop.Backend as the Startup project.
-
Right click the MyShop.Backend, Choose "Manage User Secrets" . In secrets.json add your connection string, this setting will override the ConnectionString in the appsettings.json
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=MyShop;Trusted_Connection=True;MultipleActiveResultSets=true"
}
-
Open the Package Manager Console, In the Package Manager Console windows make sure the MyShop.Backend is selected for Default project. Type
Update-Database
and press Enter -
Right click on the solution, choose properties. In the Startup Project choose Multiple startup projects: MyShop.Backend and MyShop.Frontend
- Click F5 to start
For Visual Studio Code
-
At the root folder type
dotnet build
to build the MyShop.sln solution -
Install Entity Framework Core Tools by run the command below
dotnet tool install --global dotnet-ef --version 3.0.0
-
Go to the src\MyShop.Backend open the appsettings.json update the connection string, then type
dotnet ef database update
to run migration. Then typedotnet run
to launch the backend -
Go to the src\MyShop.Frontend folder and type
dotnet run
to launch the frontend.
Authentication
All the content: brands, categories, products can be added via swagger ui. The insert/update/delete APIs are required authentication. So you will need to register an account. Then, in the swagger ui click "Authorize", a popup dialog will be showed and in the Scope you need to check on the 'api.myshop'. After authorized you can invoke methods to create brands, categories, projects including upload product thumbnails.