Fix running clean architecture template on Linux #981
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the issue where the Clean Architecture template web project cannot be run directly on Linux because it attempts to use LocalDB (SQL Server), which is not supported on non-Windows platforms.
Changes Made
InfrastructureServiceExtensions.cs: Modified to detect the operating system and skip the
DefaultConnection(LocalDB) on non-Windows platforms, automatically falling back to SQLite. Added support for aUSE_SQL_SERVERenvironment variable to force SQL Server mode when needed (e.g., for functional tests).MiddlewareConfig.cs: Updated database migration logic to use
EnsureCreated()for SQLite databases (development/local scenarios) andMigrate()for SQL Server (production scenarios).appsettings.json: Updated comments to clarify the cross-platform behavior of connection strings.
CustomWebApplicationFactory.cs: Updated functional tests to set the
USE_SQL_SERVERenvironment variable and configure the SQL Server connection from Testcontainers, ensuring tests work cross-platform.Testing
The template now works seamlessly on Linux, macOS, and Windows without any manual configuration changes.
Fixes #977
Original prompt
This section details on the original issue you should resolve
<issue_title>Clean architecture template web project cannot be run directly on linux</issue_title>
<issue_description>
10.0.100 [/usr/share/dotnet/sdk]Arch LinuxLinux ARCHDESKTOP 6.17.7-arch1-1 ardalis/CleanArchitecture#1 SMP PREEMPT_DYNAMIC Sun, 02 Nov 2025 17:27:22 +0000 x86_64 GNU/LinuxSteps to Reproduce:
Result: