Skip to content

Allow null connection string with ConfigureDataSource - #3693

Merged
roji merged 1 commit into
npgsql:mainfrom
roji:NullConnString
Dec 24, 2025
Merged

roji merged 1 commit into
npgsql:mainfrom
roji:NullConnString

Conversation

@roji

@roji roji commented Dec 23, 2025

Copy link
Copy Markdown
Member

Fixes #3692

Copilot AI review requested due to automatic review settings December 23, 2025 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables the use of ConfigureDataSource() without providing a connection string, allowing users to configure the connection details entirely through the NpgsqlDataSourceBuilder's connection string builder.

  • Removed the null connection string guard that previously prevented creating a data source without an explicit connection string
  • Added null coalescing to treat null connection strings as empty strings for dictionary key lookups
  • Added a test case verifying the new functionality with a null connection string

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/EFCore.PG/Storage/Internal/NpgsqlDataSourceManager.cs Removed null connection string guard and added null coalescing logic to support ConfigureDataSource without explicit connection string
test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs Added test case for null connection string scenario and updated ConfigurableContext to accept nullable connection string

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 23, 2025 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 24, 2025 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roji
roji enabled auto-merge (squash) December 24, 2025 13:19
@roji
roji disabled auto-merge December 24, 2025 13:34
@roji
roji merged commit a64c405 into npgsql:main Dec 24, 2025
@roji
roji deleted the NullConnString branch December 24, 2025 13:35
roji added a commit that referenced this pull request Dec 24, 2025
@roji

roji commented Dec 24, 2025

Copy link
Copy Markdown
Member Author

Backported to 9.0.5 via 4f9503f

@roji

roji commented Apr 13, 2026

Copy link
Copy Markdown
Member Author

Backported to 10.0.2 via caeb33b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConfigureDataSource ignored when UseNpgsql without ConnectionString parameter used

2 participants