For our database, we are going to use XAMPP - which is already installed on your machine. If you want it on your own machine at home you can download it from apachefriends.org.
The main difference is that at tech you will be using
localhost:9080 instead of
localhost:80 to access your website
When starting XAMPP for the first time you will need to choose a language - I recommend the american flag :-D
If all goes well, you should see the following screenshot
Click on the start button for Apache and MySQL - the others should be greyed out.
Inside of the meca_stack folder create a new project by typing in:
dotnet new webapi -o meca_api --no-https
Inside of the
meca_api folder paste the following lines to install the relevant nuget packages:
dotnet add package Pomelo.EntityFrameworkCore.MySql --version 2.2.0 dotnet add package Microsoft.EntityFrameworkCore dotnet add package Microsoft.EntityFrameworkCore.Tools dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Microsoft.Extensions.Configuration.UserSecrets --version 2.2.0
Check that your project runs by running
Open up vscode and have a look at the meca_api.csproj file - you should see the nuget packages that have been added.
Check and install the following extensions:
.gitignore file and add the following content in it from this page:
Adding sql files to the database¶
Go to http://localhost:9080/phpmyadmin or click on the admin button next to mysql in the xampp panel
You can find the sql files here
We are using EF scafholding to setup our models
dotnet ef dbcontext scaffold "Server=localhost;Database=postdb;User=root;" Pomelo.EntityFrameworkCore.MySql -o Models -f -c PostDBContext