To get the SQL connection string from entity framework using DbConetext edmx file. In this example I will show you with example.
The connection String element must be present in the web.config with specified name.
Example Connection String:
<add name="models" connectionString="metadata=res://*/Models.mydb.csdl|res://*/Models.mydb.ssdl|res://*/Models.mydb.msl;provider=System.Data.SqlClient;providerconnection string="data source......;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Solution:
You must get the connection string that used by Entity framework by using the following way.
dbContext db = new dbContext();string connstring = db.Database.Connection.ConnectionString;
Output:
Post your comments / questions
Recent Article
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
- Remove all special characters, punctuation except spaces from string - Python
- OSError: cannot write mode RGBA as JPEG- Python
- expected str, bytes or os.PathLike object, not JpegImageFile - Python
Related Article