In .NET Core applications, the default connection string provider implementation searches the appsettings.json
file in the current directory and reads connection strings from the file’s ConnectionStrings
section.
This example demonstrates how to get connection strings from a set of different configuration sources in an ASP.NET Core application.
This example implements a custom configuration and loads connection strings from various data sources. This example uses the ConfigurationBuilder class and its AddJsonFile and AddInMemoryCollection extension methods.
To register connection strings from a custom configuration globally, call the static DefaultConnectionStringProvider.AssignConnectionStrings method at the application startup.
These connection strings are available for the Report Designer's Preview to fill a report's data source and generate the resulting document.
In this example, global connection strings are read from the following sources:
appsettings.json
file;appsettings.Development.json
file;- in-memory collection.
The Report Designer obtains connection strings from a custom configuration using the RegisterDataSourceWizardConfigurationConnectionStringsProvider method at the application startup.
The obtained connection strings are shown in the SQL Data Source Wizard in the section that prompts the user to create new data sources. Note that the SQL Data Source Wizard uses only the specified set of connection strings, not including the strings registered globally.
In this example, the Report Designer's connection strings are read from the following files:
appsettings.json
appsettings.Development.json
- Startup.cs
- CustomConfigurationProvider.cs
- appsettings.json
- appsettings.Development.json
- HomeController.cs
- Designer.cshtml
- Configuration in ASP.NET Core
- Change SQL Data Source Connection Settings at Runtime
- Data Source Wizard - Choose a Data Connection
- Web Report Designer - Register SQL Data Connections
- Data Sources in Web End-User Report Designer (ASP.NET Core)
(you will be redirected to DevExpress.com to submit your response)