SQL Server Provider
LightNap supports Microsoft SQL Server as a production-ready database provider using Entity Framework Core.
Prerequisites
- SQL Server 2019 or later (or Azure SQL Database)
- Appropriate connection permissions
Configuration
Update appsettings.json:
{
"Database": {
"Provider": "SqlServer"
},
"ConnectionStrings": {
"DefaultConnection": "Server=your-server;Database=LightNap;Trusted_Connection=True;TrustServerCertificate=True;"
}
}
Azure SQL Database
For Azure SQL Database:
{
"ConnectionStrings": {
"DefaultConnection": "Server=tcp:your-server.database.windows.net,1433;Initial Catalog=LightNap;Persist Security Info=False;User ID=your-user;Password=your-password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
}
Initial Setup
- Create the database in SQL Server
- Update connection string in
appsettings.json - Run the application - migrations will apply automatically
Migrations
SQL Server migrations are stored in src/LightNap.DataProviders.SqlServer/Migrations/.
To create a new migration:
cd src
dotnet ef migrations add MigrationName --project LightNap.DataProviders.SqlServer --startup-project LightNap.WebApi
Best Practices
- Use Azure SQL Database for cloud deployments
- Enable connection pooling for better performance
- Configure appropriate firewall rules
- Use managed identity authentication in Azure
- Monitor query performance with SQL Server Profiler