@@ -21,7 +21,13 @@ public class NpgsqlRelationalConnection : RelationalConnection, INpgsqlRelationa
2121 private readonly ProvidePasswordCallback ? _providePasswordCallback ;
2222#pragma warning restore CS0618
2323
24- private DbDataSource ? _dataSource ;
24+ /// <summary>
25+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
26+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
27+ /// any release. You should only use it directly in your code with extreme caution and knowing that
28+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
29+ /// </summary>
30+ public DbDataSource ? DataSource { get ; private set ; }
2531
2632 /// <summary>
2733 /// Indicates whether the store connection supports ambient transactions
@@ -58,7 +64,7 @@ protected NpgsqlRelationalConnection(RelationalConnectionDependencies dependenci
5864 {
5965 if ( dataSource is not null )
6066 {
61- _dataSource = dataSource ;
67+ DataSource = dataSource ;
6268
6369#if DEBUG
6470 // We validate in NpgsqlOptionsExtensions.Validate that DataSource and these callbacks aren't specified together
@@ -92,9 +98,9 @@ protected NpgsqlRelationalConnection(RelationalConnectionDependencies dependenci
9298 /// </summary>
9399 protected override DbConnection CreateDbConnection ( )
94100 {
95- if ( _dataSource is not null )
101+ if ( DataSource is not null )
96102 {
97- return _dataSource . CreateConnection ( ) ;
103+ return DataSource . CreateConnection ( ) ;
98104 }
99105
100106 var conn = new NpgsqlConnection ( ConnectionString ) ;
@@ -132,12 +138,12 @@ protected override DbConnection CreateDbConnection()
132138 // TODO: Remove after DbDataSource support is added to EF Core (https://github.com/dotnet/efcore/issues/28266)
133139 public override string ? ConnectionString
134140 {
135- get => _dataSource is null ? base . ConnectionString : _dataSource . ConnectionString ;
141+ get => DataSource is null ? base . ConnectionString : DataSource . ConnectionString ;
136142 set
137143 {
138144 base . ConnectionString = value ;
139145
140- _dataSource = null ;
146+ DataSource = null ;
141147 }
142148 }
143149
@@ -155,7 +161,7 @@ public override string? ConnectionString
155161 {
156162 base . DbConnection = value ;
157163
158- _dataSource = null ;
164+ DataSource = null ;
159165 }
160166 }
161167
@@ -167,12 +173,12 @@ public override string? ConnectionString
167173 /// </summary>
168174 public virtual DbDataSource ? DbDataSource
169175 {
170- get => _dataSource ;
176+ get => DataSource ;
171177 set
172178 {
173179 DbConnection = null ;
174180 ConnectionString = null ;
175- _dataSource = value ;
181+ DataSource = value ;
176182 }
177183 }
178184
@@ -196,7 +202,7 @@ public virtual INpgsqlRelationalConnection CreateAdminConnection()
196202 Multiplexing = false
197203 } . ToString ( ) ;
198204
199- var adminNpgsqlOptions = _dataSource is not null
205+ var adminNpgsqlOptions = DataSource is not null
200206 ? npgsqlOptions . WithConnection ( ( ( NpgsqlConnection ) CreateDbConnection ( ) ) . CloneWith ( adminConnectionString ) )
201207 : npgsqlOptions . Connection is not null
202208 ? npgsqlOptions . WithConnection ( DbConnection . CloneWith ( adminConnectionString ) )
0 commit comments