Created
October 23, 2014 15:19
-
-
Save tekguy/dd717bf84639940f8f02 to your computer and use it in GitHub Desktop.
Get a SqlConnection from a DbContext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private SqlConnection GetSqlConnection(DbContext dbContext) | |
{ | |
var ec = dbContext.Database.Connection; | |
var adoConnStr = ec.ConnectionString; | |
return new SqlConnection(adoConnStr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OR Get a SqlConnection from a DbContext
public class TBill_DbConnect : DbContext
{
SqlConnection conn;