Entity Framework ObjectContext -> raw SQL calls to native DBMS

前端 未结 4 1982
旧时难觅i
旧时难觅i 2021-01-13 19:52

I have an app using the ADO.NET entity framework (the VS2008 version, not the newer, cooler one) and I need to be able to make a call down to the underlying DBMS (it\'s post

4条回答
  •  一个人的身影
    2021-01-13 20:21

    Thanks Justin. I spent hours trying to figure out why the StoreConnection property was not available on my Entity Framework connection....

    The key piece for me was the fact that you have to formally cast your EF connection as a System.Data.EntityClient.EntityConnection:

    var newConn = (System.Data.EntityClient.EntityConnection)db.Connection;

    Once I did that it everything else made sense.

提交回复
热议问题