How to point all connection string in generated strongly typed datasets to use appsettings default connectionstring in ASP.NET Core Razor pages

Olumuyiwa Afolabi 1 Reputation point
2021-12-25T06:09:38.417+00:00

How can I point all generated dataset schema connection string to use appsettings default connection string in ASP.NET Core Razor pages?

Note: this works perfectly in ASP.NET Webforms and ASP.NET MVC, but not in ASP.NET Core with Razor pages.

Generated code from dataset Xsd Schema:

private void InitConnection()
{
this._connection = new global::System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = "Data Source=(localdb)\mssqllocaldb;Initial Catalog=mylocaldb;Integrated Security=True";
}

I want the connection string to point to the appsettings.json default connection.

Thanks

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.