title: How can I specify a login\password at runtime to connect Oracle via EF6 in C#?
body: <p>I am making login window to connect Oracle from my app (C# Entity Framework Code First from existing database). I want to make user able to set his own username\password to connect with DB. I tryed to change connection string in my DbContext, but it is doesn't work. Connection string seems to be changed, but provider returns invalid login\password exception. When I am trying to connect DB with connection string whitch has stored pass everything is ok. I think there is some security reasons for this behaivor. How can I propperly change connection string in runtime?
  I am using VS 2017, Entity Framework 6, Oracle.ManagedDataAccess 18.3, Oracle 11.2 Server.</p>
  
  <p>App.config</p>
  
  <pre><code>name="ConnStrPass" connectionString="DATA SOURCE=titan;PASSWORD=REALPASS;PERSIST SECURITY INFO=True;USER ID=BEE" providerName="Oracle.ManagedDataAccess.Client"
  
  name="ConnStrNoPass" connectionString="DATA SOURCE=titan;PASSWORD=QWERTY;PERSIST SECURITY INFO=True;USER ID=BEE" providerName="Oracle.ManagedDataAccess.Client"
  </code></pre>
  
  <p>DBDemoModel.cs</p>
  
  <pre><code>public partial class DBDemoModel : DbContext
  {
      public DBDemoModel()
          : base("name=ConnStrPass")
      {
      }
  
      //overriding constructor DBDemoModel to change pass in ConnectionString
  
      public DBDemoModel(string pass)
              : base("name=ConnStrNoPass")
      {
  
          this.Database.Connection.ConnectionString = this.Database.Connection.ConnectionString.Replace("QWERTY", pass);
  
      }
  </code></pre>
  
  <p>AbonentsFinder.cs //works fine</p>
  
  <pre><code>    public List&lt;ABONENTS&gt; SelectAbonentsByName(string textToFind)
      {
          using (DBDemoModel db = new DBDemoModel())
          {
              var cont = db.ABONENTS.Where(a =&gt; a.OWNER.Contains(textToFind));
              var abon = cont.ToList();
              return new List&lt;ABONENTS&gt;(abon);
          }            
      }
  </code></pre>
  
  <p>AbonentsFinder.cs //doesn't work wrong username\login</p>
  
  <pre><code>    public List&lt;ABONENTS&gt; SelectAbonentsByName(string textToFind, string pass)
      {
          using (DBDemoModel db = new DBDemoModel(pass))
          {
              var cont = db.ABONENTS.Where(a =&gt; a.OWNER.Contains(textToFind));
              var abon = cont.ToList();  //exception
              return new List&lt;ABONENTS&gt;(abon);
          }            
      }
  </code></pre>
  
  <p>DBDemoModel.cs //System.NotSupportedException</p>
  
  <pre><code>    public DBDemoModel(string pass)
              : base(new OracleConnection("DATA SOURCE=titan; PASSWORD="+pass+";USER ID=BEE"), true)
      {
  
      }
  </code></pre>