I want to connect my project to an Sqlite database. So, in my Database Context I have this cunstructor and an Initialize method
private DatabaseContext(string cnxString) : base(cnxString) { Database.SetInitializer<DatabaseContext>(new DatabaseInitialiser()); } public static void initialize(string connx) { _instance = new DatabaseContext(connx); }
and In the program.cs I call Inialize method to set the connexion string
DatabaseContext.initialize("data source=D:\storage.sqlite;");
So, every user can connect to his database by passing his connexion string.
But, when running my application I have this error :
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.