A sample code project demonstrating a basic web application.
This project is designed for development in an environment with the following tools:
- Visual Studio Code (https://code.visualstudio.com/) (with C# extension https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
- .NET 5.0 SDK (https://dotnet.microsoft.com/download)
- PowerShell 5 or greater (may be used within VS Code or outside it)
Before the application can be run or any commands can be executed, you must initialize
the environment by invoking the env.ps1 script in PowerShell:
PS> .\env.ps1
This performs several necessary tasks:
- Sets environment variables the application requires (such as database connection string)
- Sets the current working directory to the web application project, allowing
dotnetcommands to find the project by default. (Push-Locationis used to change the working directory, soPop-Locationmay be used to return to the previous working directory.) - Creates the
.envfile required by the application launch configuration.
Common tasks are mostly performed in PowerShell.
Note that the database location is being read from the TODOLISTDB environment variable,
configured from the env.ps1 script.
-
To create and deploy changes to the database, use EF's
updatecommand:dotnet ef database update -
To create migrations, modify the database code models (in the
DbModelsnamespace) and then use EFsmigrationscommand:dotnet ef migrations add [migration-name]
To debug the application, ensure that the database is up to date (using the commands above)
and then use VS Code's built in debugger for C#. A build task and launch configuration
are already included in the project.