Skip to content

Project Setup

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

Setup

If all goes well, you should see the following screenshot

Setup

Click on the start button for Apache and MySQL - the others should be greyed out.

Setup

Inside of the meca_stack folder create a new project by typing in:

dotnet new webapi -o meca_api --no-https

Setup

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

Setup

Check that your project runs by running dotnet run

Setup

Open up vscode and have a look at the meca_api.csproj file - you should see the nuget packages that have been added.

Setup

Check and install the following extensions:

Setup Setup Setup Setup Setup Setup Setup

Create a .gitignore file and add the following content in it from this page:

https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

Setup

Setup

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

Setup Setup Setup

You can find the sql files here

https://gist.github.com/to-jk11/d714208f3036f80e566abbfdf70b4149

Setup Setup

Setup Setup Setup Setup

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 

Setup

Setup

Setup