Can I use EF4 EntityConnection in SqlConnection?

For instance:

SqlConnection connection = new SqlConnection(efContext.Connection...?)
connection.Open();

etc..
+3
source share
2 answers

Not directly, no, but you can get the Sql connection string from it and create a new connection using the property StoreConnection:

SalesSyncEntities ctx = new SalesSyncEntities();
    EntityConnection ec = (EntityConnection)ctx.Connection;
    SqlConnection sc = (SqlConnection)ec.StoreConnection;
    string adoConnStr = sc.ConnectionString;
    return adoConnStr;

Found here .

+9
source

No, the Entity Framework connection strings indicate the model files, as well as the main storage store; This is not a format that SQL Server understands.

0
source

Source: https://habr.com/ru/post/1789850/


All Articles