3.5 KiB
PackageName.CompanyName.ProjectName
Quick Start Guide
This guide will help you quickly set up and run the project. Follow these steps to get started.
Prerequisites
- .NET SDK 9.0 or higher
- A supported database (SQL Server, MySQL, PostgreSQL, Oracle, or SQLite)
- PowerShell 7.0+ (recommended for running migration scripts)
Step 1: Restore and Build the Project
# Navigate to the project root directory
cd /path/to/project
# Restore dependencies
dotnet restore
# Build the solution
dotnet build
Step 2: Create Database Schema
Use the Migrate.ps1 script to create the database tables structure:
# Navigate to the migrations directory
cd migrations
# Run the migration script
./Migrate.ps1
The script will:
- Detect available DbContext classes in the project
- Ask you to select which DbContext to use for migration
- Prompt for a migration name
- Create the migration
- Optionally generate SQL scripts for the migration
Step 3: Initialize Seed Data
Run the DbMigrator project to initialize seed data:
# Navigate to the DbMigrator project directory
cd migrations/PackageName.CompanyName.ProjectName.AIO.DbMigrator
# Run the DbMigrator project
dotnet run
The DbMigrator will:
- Apply all database migrations
- Seed initial data (users, roles, etc.)
- Set up tenant configurations if applicable
Step 4: Launch the Application
After successfully setting up the database, you can run the host project:
# Navigate to the host project directory
cd host/PackageName.CompanyName.ProjectName.AIO.Host
# Run the host project
dotnet run --launch-profile "PackageName.CompanyName.ProjectName.Development"
The application will start and be accessible at the configured URL (typically https://localhost:44300).
Database-based Unit Testing
To run database-based unit tests, follow these steps:
Step 1: Prepare Test Database
Before running tests, make sure the test database exists. The test database connection string is defined in the ProjectNameEntityFrameworkCoreTestModule.cs file.
The default connection string is:
private const string DefaultPostgresConnectionString =
"Host=127.0.0.1;Port=5432;Database=test_db;User Id=postgres;Password=postgres;";
You can either create this database manually or modify the connection string to use an existing database.
Step 2: Configure Test Environment
Modify the connection string in ProjectNameEntityFrameworkCoreTestModule.cs if needed:
// You can also set an environment variable to override the default connection string
var connectionString = Environment.GetEnvironmentVariable("TEST_CONNECTION_STRING") ??
DefaultPostgresConnectionString;
Step 3: Run Tests
Run the Application.Tests project:
# Navigate to the test project directory
cd tests/PackageName.CompanyName.ProjectName.Application.Tests
# Run the tests
dotnet test
The test framework will:
- Create a clean test database environment
- Run all unit tests
- Report test results
Note About Naming
This is a template project, so all project names contain placeholders that will be replaced when the template is used to create a new project:
PackageNamewill be replaced with your package nameCompanyNamewill be replaced with your company nameProjectNamewill be replaced with your project name
When creating a new project from this template, you'll specify these values and they'll be substituted throughout the entire solution.