Overview
This guide provides comprehensive instructions for installing and configuring the Canchas Deportivas sports field booking system. Follow these steps to set up a complete development or production environment.For a faster setup, see the Quick Start Guide. This guide covers advanced configuration, security, and production deployment considerations.
System Requirements
Software Prerequisites
.NET SDK
SQL Server
SQL Server 2019 or higherOptions:
- SQL Server Express (free)
- SQL Server Developer Edition
- Azure SQL Database
IDE
Development EnvironmentChoose one:
- Visual Studio 2022 (Community or higher)
- Visual Studio Code with C# extension
- JetBrains Rider
Git
Hardware Requirements
- CPU: Dual-core processor (2 GHz or faster)
- RAM: 4 GB minimum (8 GB recommended)
- Disk Space: 10 GB free space
- OS: Windows 10/11, Windows Server 2019+, Linux, or macOS
Installation Steps
Install SQL Server
Download and install SQL Server:For Development (SQL Server Express):
- Download from Microsoft SQL Server Express
- Run the installer and choose “Basic” installation
- Note the server instance name (typically
localhost\SQLEXPRESS) - Install SQL Server Management Studio (SSMS) for database management
- Use SQL Server Standard/Enterprise edition
- Or Azure SQL Database for cloud deployment
Restore NuGet Packages
Navigate to the solution directory and restore dependencies:This will install:
- Microsoft.Data.SqlClient (v6.1.2) - SQL Server connectivity
- Microsoft.VisualStudio.Web.CodeGeneration.Design (v8.0.7) - Scaffolding tools
Configure Database Connection
Update the connection string in the data layer:File: Connection String Components:
source/capa_dato/CD_conexion.cscapa_dato/CD_conexion.cs
Data Source: Your SQL Server instance (e.g.,localhost\SQLEXPRESS)Initial Catalog: Database name (DB_canchasdeportivas)Integrated Security=True: Use Windows AuthenticationEncrypt=True: Encrypt connectionTrust Server Certificate=True: Trust self-signed certificates
- Windows Authentication
- SQL Server Authentication
- Azure SQL Database
Create Database Schema
Open SQL Server Management Studio (SSMS) and connect to your server.Create the Database:Create Tables:
Create Stored Procedures
The application uses stored procedures for all data operations. Create them in SQL Server:Reservas Stored Procedures:
Create similar stored procedures for Canchas, Clientes, and Usuarios tables following the same pattern (List, Insert, Update, Delete).
Configure Application Settings
Update For development environment (
appsettings.json in the presentation layer:File: source/capa_presentacion/appsettings.jsonappsettings.Development.json):Run the Application
Start the web application:Or for development with hot reload:The application will start and display:
Verify Installation
Open a browser and test these endpoints:
- Home:
http://localhost:5000/ - Reservations List:
http://localhost:5000/Reservas/ListarReservas - Create Reservation:
http://localhost:5000/Reservas/InsertarReservas - Sports Fields:
http://localhost:5000/Canchas - Clients:
http://localhost:5000/Clientes - Search Reservations:
http://localhost:5000/Reservas/BuscarReservaNombre
Project Architecture
Understanding the three-tier architecture:capa_presentacion
Presentation LayerASP.NET Core MVC controllers and views. Handles HTTP requests, renders UI, and manages user interactions.Key files:
- Controllers (ReservasController, CanchasController)
- Views (Razor .cshtml files)
- wwwroot (static assets)
capa_negocio
Business Logic LayerContains business rules, validation, and orchestration between presentation and data layers.Classes: CN_Reservas, CN_Canchas, CN_Clientes
capa_dato
Data Access LayerManages database connections and executes stored procedures. Uses ADO.NET with SqlConnection.Key components:
- CD_conexion (connection management)
- CD_Reservas, CD_Canchas (data operations)
capa_entidad
Entity LayerDomain models and ViewModels shared across all layers.Entities: CE_Reservas, CE_Canchas, CE_Clientes, ReservaViewModel
Configuration Options
Connection String Best Practices
Option 1: Environment VariablesApplication Settings
ModifyProgram.cs to add services:
capa_presentacion/Program.cs
Troubleshooting
Cannot connect to SQL Server
Cannot connect to SQL Server
Symptoms:
SqlException: A network-related or instance-specific errorSolutions:- Verify SQL Server is running:
- Enable TCP/IP in SQL Server Configuration Manager
- Check firewall allows SQL Server port (default 1433)
- Verify server name in connection string
- Test with SQL Server Management Studio first
Stored procedure not found
Stored procedure not found
Symptoms:
SqlException: Could not find stored procedure 'SP_Reservas_List'Solutions:- Verify database is selected:
- Check stored procedures exist:
- Recreate missing stored procedures from Step 7
- Ensure correct database in connection string
Authentication failed for user
Authentication failed for user
Symptoms: Login failed for user ‘NT AUTHORITY\SYSTEM’Solutions:
- For Windows Authentication: Add your Windows user to SQL Server logins
- For SQL Authentication: Create SQL login and grant permissions:
Build errors - project references
Build errors - project references
Symptoms: Project reference errors or missing typesSolutions:
- Clean and rebuild:
- Verify project references in .csproj files
- Restore NuGet packages:
Port already in use
Port already in use
Symptoms:
IOException: Failed to bind to address http://127.0.0.1:5000Solutions:- Change port in
Properties/launchSettings.json - Or specify port at runtime:
- Kill process using the port (Windows):
Views not found - 404 errors
Views not found - 404 errors
Symptoms: 404 or view not found errorsSolutions:
- Verify view files exist in correct folders:
Views/Reservas/ListarReservas.cshtmlViews/Canchas/...Views/Shared/_Layout.cshtml
- Check controller action names match view names
- Ensure
_ViewImports.cshtmland_ViewStart.cshtmlexist
Production Deployment
Publishing the Application
Create a production build:IIS Deployment
Install ASP.NET Core Hosting Bundle
Download and install from dotnet.microsoft.com
Create IIS Application Pool
- Open IIS Manager
- Create new Application Pool
- Set .NET CLR Version to “No Managed Code”
- Set Managed Pipeline Mode to “Integrated”
Deploy Application
- Copy published files to IIS directory (e.g.,
C:\inetpub\wwwroot\canchas) - Create IIS site pointing to the directory
- Assign the application pool created in step 2
Docker Deployment
Create aDockerfile:
Security Considerations
- Password Hashing: Never store plain text passwords. Use
BCrypt.NetorPasswordHasher - SQL Injection Prevention: The application uses parameterized stored procedures, which protects against SQL injection
- Input Validation: Add data annotations and server-side validation
- HTTPS: Always use HTTPS in production
- Connection String Security: Store in Azure Key Vault or environment variables
- Authentication: Implement ASP.NET Core Identity for user management
Next Steps
Architecture Overview
Learn about the three-tier architecture and design patterns used
API Reference
Explore controllers, models, and data access methods in detail
Features
Learn about managing sports fields and reservations
Database
Configure your database connection and stored procedures
Congratulations! You have successfully installed Canchas Deportivas. For questions or issues, refer to the troubleshooting section or check the API reference for implementation details.