entity framework - Entityframework code based config -


i'm trying rid of app.config entityframework (v6) settings , move code (don't want deploy config connection string , password).

following exception thrown on opening: system.data.entity.core.entityexception: underlying provider failed on open.

i'm using sqlite3 db encryption , database first entity model.

[dbconfigurationtype(typeof(databaseconfiguration))] public partial class testentities : dbcontext {     public testentities () :         base((databaseconfiguration.getconnectionstring("testentities", @"\\\\abt\01_tools\test\db\test.db", "somedummypw")))     {     }      protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         throw new unintentionalcodefirstexception();     }      public virtual dbset<employee> employees { get; set; } }  public class sqliteconnectionfactory:idbconnectionfactory {     public dbconnection createconnection(string nameorconnectionstring)     {         return new sqliteconnection(nameorconnectionstring);     } }  public class databaseconfiguration:dbconfiguration {     public databaseconfiguration()     {         setdefaultconnectionfactory(new sqliteconnectionfactory());         setproviderfactory("system.data.sqlite", sqlitefactory.instance);         setproviderfactory("system.data.sqlclient", sqlclientfactory.instance);         setproviderfactory("system.data.sqlite.ef6", sqliteproviderfactory.instance);         //setproviderfactory("system.data.entityclient", entityproviderfactory.instance);          setproviderservices("system.data.sqlite.ef6", (dbproviderservices)sqliteproviderfactory.instance.getservice(typeof(dbproviderservices)));     }      public static string getconnectionstring(string efmodelname, string databasefilepath, string password)     {         // initialize connection string builder underlying provider.         sqlconnectionstringbuilder sqlbuilder = new sqlconnectionstringbuilder         {             datasource = databasefilepath,             password = password         };          // initialize entityconnectionstringbuilder.         entityconnectionstringbuilder entitybuilder = new entityconnectionstringbuilder();         entitybuilder.provider = "system.data.sqlite.ef6";          // set provider-specific connection string.         entitybuilder.providerconnectionstring = sqlbuilder.tostring();          // set metadata location.         entitybuilder.metadata = string.format(@"res://*/model.{0}.csdl|res://*/model.{0}.ssdl|res://*/model.{0}.msl", efmodelname);          return entitybuilder.connectionstring;     } } 

any ideas?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -