diff --git a/src/Marten/StoreOptions.cs b/src/Marten/StoreOptions.cs index 184cfc345d..e200f26837 100644 --- a/src/Marten/StoreOptions.cs +++ b/src/Marten/StoreOptions.cs @@ -523,6 +523,26 @@ NpgsqlDataSource dataSource Connection(dataSource); } + /// + /// Apply additional configuration to every NpgsqlDataSourceBuilder created by Marten, + /// including those for tenant databases. Use this to register Npgsql plugins like + /// UseVector() (pgvector), UseNodaTime(), UseNetTopologySuite(), etc. + /// + /// Action applied to each NpgsqlDataSourceBuilder before Build() is called + public void ConfigureNpgsqlDataSourceBuilder(Action configure) + { + var original = NpgsqlDataSourceBuilderFactory; + NpgsqlDataSourceBuilderFactory = cs => + { + var builder = original(cs); + configure(builder); + return builder; + }; + + // Rebuild the data source factory so it uses the updated builder factory + NpgsqlDataSourceFactory = new DefaultNpgsqlDataSourceFactory(NpgsqlDataSourceBuilderFactory); + } + /// /// Override the JSON serialization by ISerializer type ///