Connection string in asp.net core
Loading
Connection string in asp.net core
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajesh GamiPosted Nov 15, 2022, 12:55 PM
ASP.NET Core
In ASP.NET Core the configuration system is very flexible, and the connection string could be stored in
appsettings.json, an environment variable, the user secret store, or another configuration source. See the Configuration section of the ASP.NET Core documentation for more details.For instance, you can use the Secret Manager tool to store your database password and then, in scaffolding, use a connection string that simply consists of
Name=.Or the following example shows the connection string stored in
appsettings.json.Then the context is typically configured in
Startup.cswith the connection string being read from configuration. Note theGetConnectionString()method looks for a configuration value whose key isConnectionStrings:. You need to import the Microsoft.Extensions.Configuration namespace to use this extension method.Rajeesh MenothPosted Nov 15, 2022, 12:23 PM
Hi Naresh,
You can explain a bit more about your question? As a simple answer Connection string is an exact replacement of Web config ( Old ASP.NET Projects ).
Reference :
https://stackoverflow.com/questions/68980778/config-connection-string-in-net-core-6
Rajanikant HawaldarPosted Nov 15, 2022, 8:01 AM
https://www.c-sharpcorner.com/Blogs/database-connections-in-asp-net-core-20
Vishal YelvePosted Nov 15, 2022, 6:14 AM
In ASP.NET Core the configuration system is very flexible, and the connection string could be stored in
appsettings.json, an environment variable, the user secret store, or another configuration source.In appsettings.json
Then the context is typically configured in
Startup.cswith the connection string being read from configuration. Note theGetConnectionString()method looks for a configuration value whose key isConnectionStrings:. You need to import the Microsoft.Extensions.Configuration namespace to use this extension method.for more details please refer below link
https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-strings