Value cannot be null (Parameter 'connectionString')


value cannot be null. (parameter 'connectionstring')


Key scenarios


Usually during application development (asp.net core, Web Api, blazor, Entity Framework, Azure and .net core) issues arise, and challenges the developer. This article covers a specific error "Value cannot be null. (Parameter 'connectionString') provides a step by step solution.  

There are possible development scenarios this error could be prompted related to connectionString.  While add-migration, Entity Framework migration, Azure Function, update-database, sqlite, .net core, asp.net core.

What is covered in this article?

  • Error captured with detailed description
  • Reason for this error 
  • The quick and easy step-by-step solution provided

What is the Error Captured? 

The exception message captured 'System.ArgumentNullException'  on the parameter connectionString value is null.  This error clearly explain that the project handling the connectionString is unable to identify.


Value cannot be null. (Parameter 'connectionString')


When you run the application project, the exception captured at the Configuration Services method of the Startup.cs like this,

Configuration Service Method


  What is the reason for this Error?

The easy way to identify the solution is why not read the error description twice! 

Parameter connectionString is null

To emphasize on the highlighted circled image above, "Parameter connectionString"  is causing the error. So to narrow down the issue go to the connectionString defined in the project. 

If working with ASP.NET project you may find it in "web.config", if ASP.NET Core MVC, Web API go to project solution and locate "appSettings.json" or "appSettings.Development.json

And the connectionString looks like this,

appSettings.Development.json

So far the connection string is valid and everything looks okay, but not sure what caused the error?  

The error occurred only from the "ConnectionString" arrow point highlighted.


 What is the Solution? 

Generally when working with the projects the number code  we type there is high chance that "Typo" causing compilation error, un-identified property not matching the declaration value. 

Similarly as described in the article the root cause for was typo in the "ConnectionString".

It should be "ConnectionStrings"  not "ConnectionString"  - a letter 's'  was missing. 

Please find the image below to distinguish between error and solution clarified. 


[Solved] value cannot be null. (parameter 'connectionstring')


Summary 

This article helps to identity the exception captured and detailed, the reason for the error and finally step-by-step solution provided. 

Errors never unavoidable in application development but sometimes a simple Typo could eat our development time a lot. So this article may help to solve the error in detailed directs to solve the problem. 

You may find similar article "typo" caused  solved inconsistent-accessibility  

NuGet VisualStudio ServicePointManager does not support proxies with https scheme