Dear Sir,
Can i call multiple connection string use in .Net Core like ADO.Net and entity framework both . Please advise me. If any solution please give me.
Thanks
Rajesh Kumar
Dear Sir,
Can i call multiple connection string use in .Net Core like ADO.Net and entity framework both . Please advise me. If any solution please give me.
Thanks
Rajesh Kumar
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.
Rajeesh MenothPosted Jan 19, 2023, 2:16 PM
Hi,
Possible and you can inject the connection strings in the startup class.
App settings should be in the following format.
Reference :
https://stackoverflow.com/questions/41525856/using-multiple-connection-strings
Sandhiya PriyaPosted Jan 2, 2026, 11:51 AM
Yes, you can absolutely use multiple connection strings in .NET Core, and you can use them together with ADO.NET and Entity Framework Core in the same application. This is very common in real projects.
Below is a clear, short, and practical explanation.
1. Define multiple connection strings (appsettings.json)
You can add any number of connection strings.
2. Use connection string with Entity Framework Core
Program.cs / Startup.cs
EF Core will use EFConnection only.
3. Use connection string with ADO.NET
ADO.NET will use ADOConnection.
4. Use BOTH EF Core and ADO.NET in the same service (Recommended)
This is fully supported
Clean and maintainable
Best for legacy + new code
5. Using multiple DbContexts (optional)
If you want multiple databases with EF Core:
When should you mix EF Core & ADO.NET?
Rajeev KumarPosted Mar 14, 2023, 7:26 AM
Hi
Yes you can use Both connectionstrings as below-
{ "ConnectionStrings": { "DefaultConnection": "Server=.\\SQLEXPRESS;Database=Bar;Trusted_Connection=True;MultipleActiveResultSets=true", "NewConnection": "Server=.\\SQLEXPRESS;Database=Bar;Trusted_Connection=True;MultipleActiveResultSets=true" } }
Satya KarkiPosted Jan 23, 2023, 7:20 AM
Yes, you can use multiple connection strings in the same app. Check the implementation example below.
https://stackoverflow.com/questions/41525856/using-multiple-connection-strings
Hammad MaqboolPosted Jan 20, 2023, 3:44 PM
Yes you can
in appsettings.json file use the following syntax to define connection strings
Rajan KumarPosted Jan 20, 2023, 7:10 AM
yes you use for both like:
{ "ConnectionStrings":
{
"myconnectionstring1": "Server=1.1.1;Database=database1;Trusted_Connection=True;",
"myconnectionstring2": "Server=1.1.2;Database=database2;Trusted_Connection=True;" }
}
and Now we can read it in our code by calling the GetConnectionString method in the Microsoft.Extensions.Configuration namespace. like thiis type:
string connectionstring1= _configuration.GetConnectionString("myconnectionstring1");
string connectionstring2= _configuration.GetConnectionString("myconnectionstring2");
Aravind GovindarajPosted Jan 19, 2023, 6:44 PM
Yes you can make it..
Create one class for Ado connection initiation and another for your dbcontext...
Rajesh GamiPosted Jan 19, 2023, 2:39 PM
Yes, You can use both
To define the connection strings in appsettings.json it is important to specify it in the right section of the JSON structure.
Now we can read it in our code by calling the GetConnectionString method in the Microsoft.Extensions.Configuration namespace.
To be able to call the method you must import the Microsoft.Extensions.Configuration namespace like this:
Vishal YelvePosted Jan 19, 2023, 1:42 PM
Yes you can use both
Naimish MakwanaPosted Jan 19, 2023, 10:58 AM
Hello Rajesh,
Please refer below link.
https://code-maze.com/aspnetcore-multiple-databases-efcore/
Thanks
Naimish Makwana
Sachin SinghPosted Jan 19, 2023, 10:47 AM
Yes, you can use both, even i have used both in multiple projects.
Jignesh KumarPosted Jan 19, 2023, 10:26 AM
Yes yo can use both togather,
https://social.msdn.microsoft.com/Forums/en-US/37176d9c-f27c-4c7a-954f-f78e6866ed9a/adonet-and-entitty-frame-work-together-in-a-project?forum=aspdotnetcore