I have a SQLite Database that I access using System.Data.SQLite. The database is read into my Entity Framework Objectcontext. However, I also need direct access to the database in certain cases.
- Can I / Should I use the same connection that my Entity Framework object context is using? I.e.
ObjectContext.Connection
? - If yes, how can I access it? Casting
Entities.Connection
toSQLiteConnection
results in "Unable to cast object of type 'System.Data.EntityClient.EntityConnection' to type 'System.Data.SQLite.SQLiteConnection'." - If not, should I create a seperate connection, open it and keep it open for the application duration, or should I open and close the connection every time I want to access the database with it?