1. EF Connection String

2. this is my connection string using ADO.NET

how to re use connection string in EF using ADO.NET
1. EF Connection String

2. this is my connection string using ADO.NET

how to re use connection string in EF using ADO.NET
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.
Prasad RaveendranPosted Jul 22, 2023, 12:08 AM
In ADO.NET, Entity Framework (EF) connection strings can be reused by extracting the connection string from the EF DbContext and then using it to create a new ADO.NET SqlConnection object. Here's how you can do it:
First, you need to obtain the connection string from the EF DbContext. If you have already configured your EF DbContext and are using the DbContext class, you can access the connection string through its Database property.
If you are using EF Core (Entity Framework Core), the process is slightly different:
Create ADO.NET SqlConnection:
Now that you have the EF connection string, you can use it to create a new ADO.NET SqlConnection object and use it in your ADO.NET code.
By reusing the EF connection string, you can leverage the same database connection for both Entity Framework and ADO.NET operations within the same application, which can be useful when you need to perform low-level data access or optimize specific queries while still benefiting from the high-level abstraction that EF provides. However, keep in mind that mixing different data access approaches should be done with caution to avoid potential issues.
Rolando PunoPosted Jul 23, 2023, 1:21 AM
Thank you so much