In .NET Core Applications using Entity Framework Core, the connection string can be configured using the AddDbContextextension method which can be used in the Startup class using the IServiceCollection.
In Entity Framework Core, connection string can also be configured to DbContext using ASP.NET Core MVC applications and .NET Core Console application.
Earlier in ASP.NET, the connection string was stored on the web.config file, but now ASP.NET core can extract and read connection strings from different locations such as appsettings.json, command-line arguments, and the environment variable, etc.
ASP.NET Core uses the Model-View-Architecture (MVC) Pattern, this model separates the application into three main groups, model, view and controller.
These groups work together to provide the required results from the model.
In any of the MVC Applications using the Entity Framework Core, the DbContext is injected using dependency injection in the ConfigureServices method.
Configure Services method comes in startup class, which means that connection strings are also required in the Startup Class.
To read from the Startup Class, an IConfiguration object is required, which can be injected from Dependency injection.
To inject into a Startup class, the developers can use a constructor or a GetConnectionString method.