Skip to Content
TORMAOT and source generation

AOT and source generation

On this page

TORM uses module initialization and compile-time generation for relational provider registration. TORM/samples/TORM.AotDemo demonstrates schema creation, CRUD, named projections, aggregation, transactions and bulk writes.

Compile-time assets

Align core, provider and generator versions. Analyzer assets included by the packages supply initialization support. When referencing projects directly, preserve their actual analyzer settings such as OutputItemType="Analyzer" and ReferenceOutputAssembly="false".

The current SqliteModuleInitIncrementalGenerator detects the four relational providers from compilation references and emits direct registration under [ModuleInitializer]. Normal package consumption includes these analyzer assets. Copying only runtime DLLs can leave provider registration missing.

Register custom drivers through DbProviderFactory.Register before creating clients.

Models and JSON

Retain metadata for entities, properties and named DTOs. Verify reads and writes in the trimmed or Native AOT output.

Custom JSON-column types, cursor keys and containers need separate System.Text.Json metadata. Register an application context during initialization; see TUtility JSON.

Publishing checks

Publish for the target platform, RID, driver and native dependencies, then verify the database and JSON operations used by the trimmed application.

AOT support for time-series clients depends on their protocol drivers and native libraries.