This project is a boilerplate template for creating a Web API using ASP.NET Core 6. It implements the Repository Pattern and uses Entity Framework Core for data access. This template is designed as a starter point for any ASP.NET Core Web API project, providing a clean and modular codebase with sample data.
- ASP.NET Core 6: Leverages the latest features and improvements in ASP.NET Core 6.
- Repository Pattern: Provides a clean separation of concerns and makes it easy to swap out data storage methods.
- Entity Framework Core: Uses EF Core for data access, making it easy to query and manage data in a database.
- Sample Data: Includes sample data models and seed data for easy setup and testing.
- Swagger Integration: Pre-configured Swagger UI for API testing and documentation.
Follow these instructions to get the project up and running:
- .NET SDK 6.0
- SQL Server or any compatible database (if using EF Core)
- Clone the repository:
git clone https://github.com/wiselinjayajos/ASP.NET-Core-6-Web-API-Repository-Pattern.git
- Navigate to the project directory:
cd ASP.NET-Core-6-Web-API-Repository-Pattern
- Restore the packages:
dotnet restore
- Update the database (if using EF Core): (As this code is not using db, this can be skipped)
dotnet ef database update
- Run the application:
dotnet run
The API will be accessible at https://localhost:5001 or http://localhost:5000.
The project follows a modular structure:
- Controllers: API controllers for handling HTTP requests.
- Repositories: Interfaces and implementations for accessing data.
- Services: Business logic layer that interacts with repositories and is used by controllers to handle API requests.
- Models: Data models representing entities in the database.
- Data: This boilerplate is using sample data (static data).
- Customize the models, repositories, and controllers according to your project's requirements.
- Update the connection string in appsettings.json to point to your database.
- Use Swagger (/swagger/index.html) for testing and documentation.
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project useful, consider supporting me by buying me a coffee! ☕