A simple ASP.NET Core Web API to track job applications.
Supports two types of data storage repositories:
- Entity Framework Core with SQL Server
- JSON file persistence
- CRUD operations for job applications
- Repository pattern with EF Core and JSON file implementations
- Swagger UI for API testing
- Asynchronous programming for better scalability
- .NET 8 SDK
- SQL Server Express (or any SQL Server instance)
- Visual Studio 2022 or Visual Studio Code
- SQL Server Management Studio (SSMS) for database management
Make sure your project has the following NuGet packages installed:
Microsoft.EntityFrameworkCoreMicrosoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.ToolsSwashbuckle.AspNetCore(for Swagger)
You can install them via the Package Manager Console in Visual Studio:
Install-Package Microsoft.EntityFrameworkCore
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Swashbuckle.AspNetCoreOr via the .NET CLI
dotnet add package Microsoft.EntityFrameworkCoredotnet add package Microsoft.EntityFrameworkCore.SqlServerdotnet add package Microsoft.EntityFrameworkCore.Toolsdotnet add package Swashbuckle.AspNetCore
Update your appsettings.json with your SQL Server connection string.
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS01;Database=JobApplicationDb;Trusted_Connection=True;MultipleActiveResultSets=true"
}Run the following commands in your project root directory (where your .csproj is):
dotnet ef migrations add InitialCreatecreates the initial migration scripts based on your DbContext and models.dotnet ef database updateapplies the migration and creates the database with the required tables.
Run your API project using Visual Studio or from the command line:
dotnet runBy default, Swagger UI will be available at:
https://localhost:{port}/swagger
Use Swagger to test the API endpoints like GET, POST, PUT, DELETE for job applications.
builder.Services.AddScoped<IJobApplicationRepository, JobApplicationEfRepository>();
builder.Services.AddScoped<IJobApplicationService, JobApplicationService>();
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();- Use Entity Framework repository for production and SQL Server.
- Use JSON file repository for quick testing or if you want to persist data without a database.
- The repository interface is async to support scalability and efficient IO.
If you get errors running EF commands:
- Make sure your terminal's current directory is the folder containing the
.csprojfile. - Ensure
Microsoft.EntityFrameworkCore.Toolsis installed. - If your database doesn't update after POSTing new data, check if the repository calls
SaveChanges()correctly.