Reputation: 963
Using: Visual Studio Community 2015 + C# + Entity Framework 6.2 + SQlite2
I know how to protect a SQlite database as I use the below code to attach password to it :
using (sqlite2 = new SQLiteConnection("Data Source=ModuleUserDB.db"))
{
//Set password
sqlite2.SetPassword("this is my password");
}
But this doesn't work with Entity Framework.
I read this post How to in-code supply the password to a connection string in an ADO.Net Entity Data Model
but I can't figure out the solution for my case
ModuleUserDBEntities
ModuleUserDB.db
Trying to modify the constructor with:
public partial class ModuleUserDBEntities : DbContext
{
public ModuleUserDBEntities() : base("name=ModuleUserDBEntities")
{
// Set the password of the database
this.Database.Connection.ConnectionString = @"Data Source=.\;Initial Catalog=ModuleUserDB.db;Persist Security Info=True;User ID=sa;Password=myownpassword";
}
}
But Visual Studio gets stuck.
What is the simplest connection string to use for this case?
Upvotes: 1
Views: 341
Reputation: 5738
Give ChangePassword
method a try.Sample :
using (sqlite2 = new SQLiteConnection("Data Source=ModuleUserDB.db"))
{
sqlite2.Open(); //You must open the connection first
sqlite2.ChangePassword("password here");
}
Upvotes: 2