Password protected SQLite DB with Entity Framework 6
I’m having a hard time getting Entity Framework 6 to work with a password encrypted file. I’ve tried several things the last few days and just cannot get it to work, I always get an error stating that the file is encrypted. My connection string with a password looks like this:
That was generated using the ADO.net database first designer. I’ve also tried using the ADO database first provider to read the encrypted database and that didn’t work either. The test button works when I enter the password but the model won’t generate. I’ve also tried including the version number in the connection string, same error.
I’ve tried using the context constructor to pass in a SQLite connection instead of the default dbConnection. That always tries to throw me into an onModelCreated event. That looked like this:
The open and close methods work, but like I said I get an OnModelCreated event thrown which keeps me from actually using the database. I’ve also tried using the default connection:
Which gives me the same encryption error. I can cast the default constructor’s dbConnection as a SQLiteConnection and set the password, open and close it but still get the encryption error. I can also set the password on the above connection with the SQLiteConnection constructor and open and close the database there as well.