1.3: API Project Creation

Enter the following command in your command line (assuming you are in your project directory):

dotnet new webapi --output EFConnect.API --name EFConnect.API

This scaffolds out a basic API project in your folder.

Let's see what files it created. Open up the folder in VS Code by using this command:

cd EFConnect.API
code .

When you open VS Code, you may get a message: Required assets to build and debug are missing from 'EFConnect.API'. Add them? Select Yes."

This adds a .vscode folder with low-level configurations that we won't be working with, but will aid our development behind the scenes.

Run and Test the Application

Run the application in the command line:

dotnet run

This will start the application running on port 5000.

Once it is running, open Postman and perform a GET request to http://localhost:5000/api/values.

You should get a 200 Status Code and a response of an array of two strings: "value1" and "value2."

Postman test

Nice! Everything is hopefully working.

Stop the server with ctrl + c.

Try starting the server using a slightly different command: dotnet watch run This will restart the server when you make changes to your application. Helpful for not switching back and forth between the terminal!

Last updated