Startup the Required Services

Before you can start running the app, you need to set up the required services such as the database and or redis cache.

Use Docker-Compose
  1. Startup your docker desktop, which is one of the tools you've had to setup as part of the prerequisites setup
  2. Open a powershell/terminal instance and navigate to the root directory of the project. There should be a docker-compose.yml file located in the root.
    Root Directory Example
  3. Run the following command to start the required services.
    docker-compose up -d
    It should startup the following services
    Docker Compose Services
  4. After starting the docker services, connect to the sql server database using your preferred tool. The username is sa and you can get the password from the docker-compose.yml file.
    After connecting to the database, create the CleanDotNet database.
Use your own SqlServer and Redis instance
  1. Open the project using your preferred IDE.
  2. Navigate to and open the /src/Api/appsettings.json file.
  3. Locate the SqlServer and Redis section and replace with details of your own instance.
    Redis and SqlServer setting
Important

The EnableSchemaMigration feature ensures that your database schemas are set up correctly when the application is run for the first time. It also handles ongoing database schema changes automatically, eliminating the need for manual intervention during development or deployment.

This feature is particularly useful in environments where continuous integration and deployment (CI/CD) pipelines are used, as it ensures that the database is always in sync with the application's data model. By enabling schema migration, you can focus on building features without worrying about database setup or schema updates. If you wish to manage your database schema manually, you can disable this setting.

For more details on how EnableSchemaMigration works and how to configure it, please refer to the Database Guide page.

Running the Project

If you are using Visual Studio 2022, follow these steps to run the project:

  1. First, ensure that the project compiles successfully. You can build the project by pressing Ctrl + Shift + B in Visual Studio 2022.
  2. Once the project is built, set the API project as the startup project. You can do this by right-clicking on the API project in the Solution Explorer and selecting Set as Startup Project.
    Startup Project Example
  3. After setting the startup project, run the application by pressing F5. This will launch the application, and you will be directed to the home page.