Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null connection string to be passed to UseProvider methods #26869

Closed
dotdiego opened this issue Dec 1, 2021 · 1 comment · Fixed by #28460
Closed

Allow null connection string to be passed to UseProvider methods #26869

dotdiego opened this issue Dec 1, 2021 · 1 comment · Fixed by #28460
Assignees
Labels
area-dbcontext closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported providers-beware type-enhancement
Milestone

Comments

@dotdiego
Copy link

dotdiego commented Dec 1, 2021

After using a workaround to handle #25555 (using a --Configuration Bundle during generation)

I'm faced with another bug when trying to apply the bundle.

When i'm using

./bundle.exe --connection "Server=(localdb)\\mssqllocaldb;Database=MyAppDb;Trusted_Connection=true;"

Case : there are no appsettings.json or none with a correct connectionString in the same folder as bundle.exe

Value cannot be null. (Parameter 'connectionString')

It's like the bundle.exe doesn't even look at the parameter connection because there are no connectionString in appsettings.json.

Case : appsettings.json with a correct connectionString exists and use the --connection parameter

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 50 - Local Database Runtime error occurred. The instance name of the local database specified is not valid.

Last sentence of the error is translated, because it was originally in french.

Yet when i put the same connection string in an appSettings.json it works perfectly and doesn't trigger this network-related error.

Include provider and version information

EF Core version: 6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6
Operating system: W10
IDE: VS 2022
dotnet-ef tools : 6.0.0

@ajcvickers ajcvickers changed the title Migrations Bundle : Value cannot be null. (Parameter 'connectionString') Allow null connection string to be passed to UseProvider methods Dec 3, 2021
@ajcvickers
Copy link
Member

Note from triage: we allow UseSqlServer, etc., to be called with no parameter for cases when the connection string is going to be set later, or is not needed at all. However, we should also allow passing null so that conditional code is not needed when the connection string is not available in tooling scenarios, such as described in this issue.

See also #23085.

@ajcvickers ajcvickers self-assigned this Dec 3, 2021
@ajcvickers ajcvickers added this to the 7.0.0 milestone Dec 3, 2021
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 15, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-rc1 Jul 22, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-rc1, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dbcontext closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported providers-beware type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants