How lerocha/chinook-database works
Project type and purpose
• This is an open-source code-generation library (ChinookDatabase) plus a test harness (ChinookDatabase.Test).
• Its purpose is to generate a sample “Chinook” database schema and data scripts for multiple SQL vendors (SQL Server, Oracle, MySQL, etc.) via T4 templates, and to validate those scripts against live database instances.
File structure
• Top-level solutions:
• ChinookDatabase (class library, .NET 8)
• ChinookDatabase.Test (test project with fixtures for each vendor)
• docker-compose.yml (brings up containerized DB servers for integration tests)
• Key directories in ChinookDatabase:
• DataModel: C# POCOs representing tables (Album, Artist, Customer, etc.)
• DataSources:
– ChinookDataSet.xsd / .json: dataset definition + sample data
– T4 templates (.tt / .ttinclude)
– Pre-generated SQL scripts (.sql, .sqlite) and batch files to seed databases
• DdlStrategies: IDdlStrategy + concrete classes per vendor (SqlServerStrategy, OracleStrategy, etc.) implementing the Strategy pattern for DDL generation
• Utilities: helpers for DataSet manipulation
• _T4Templates: central .tt files orchestrating codegen
• ChinookDatabase.Test:
• Fixtures for each database type that use the generated scripts to create a live DB and run validation queries
• appsettings.test.json: connection strings
README for additional insights
• Emphasizes T4-based autogeneration of SQL scripts from a single model/data source.
• Requires Visual Studio T4 engine + .NET 8.
• Scripts are intended for demos and ORM testing.
• Docker Compose file can bring up all supported DB servers for CI integration.