This project template tailored for backend development using C# .NET. Whether you're a newcomer to backend development or an experienced developer looking for a streamlined setup, this template provides a solid foundation to kickstart your project.
Now that you have a solid foundation, feel free to explore and extend the template to suit your project requirements. Whether you're building a small-scale application or a large-scale enterprise solution, this template provides a robust starting point for your backend development journey.
- Newcomers to Backend Development: Get up and running quickly with a project that's ready to run out of the box.
- C# .NET Developers: Utilize the latest features of .NET 8 for efficient backend development.
- Database Enthusiasts: Connect seamlessly to popular SQL databases like SQL Server, PostgreSQL, and SQLite.
- API Development with ORM: Implement Object-Relational Mapping (ORM) techniques effortlessly using Entity Framework.
- Minimal Configuration: Minimize setup time and focus on coding with pre-configured settings.
- Standardized connection strings for SQL databases ensure smooth integration.
- Automatic database connection checks before server initialization.
- CORS policies are pre-configured to prevent blocking when accessing APIs from different origins.
- Integrated Swagger UI with pre-configured XML documentation for clear API documentation and exploration.
- Filters in place to structure API responses and provide meaningful error messages, enhancing client-side handling.
- Newtonsoft.Json NuGet package is included for efficient JSON serialization and deserialization.
- Provision of examples for standard SQL table schema creation, model definition, and DbContext declaration.
- Visual Studio 2019 or above
- .NET 8 SDK installed
- ASP.NET and web development workload installed
- SQL Server and SQL Server Management Studio if you use SQL Server database
- PostgreSQL and pgAdmin 4 if you use PostgreSQL database
- A
.db
file saved from SQL Online IDE if you use SQLite database
In this guidance, I take SQL server as the example for database connection.
- Download the template HERE but do not extract the package after downloading
- Place the template in the following folder. The folder name may vary depending on your Visual Studio version.
...\Document\Visual Studio 2022\Templates\ProjectTemplates
- In the
appsettings.json
file, input information for the connection string. You only need to input the information for the database that you want to use. - In the
DatabaseConnectionChecking.cs
file, input the type of your SQL database. Specify your SQL database type by modifying SqlServer to the desired database (SqlServer, Sqlite, or Npgsql). - In the NuGet Package Manager, find and install the NuGet package coresponding to your database type which is mentioned in
Program.cs
file - In the
Program.cs
file, enable only your database type by removing the Comment remark
- Create the models and controllers as needed
- Register your models in the
ApiDbContext.cs
file - Optionally apply the provided filters to your controller classes.
- The template is pre-configured for SQL Server; consider PostgreSQL for large-scale projects with extensive datasets and SQLite for smaller projects with simpler database schemas.
- Tailor the template to your specific project requirements and database preferences.