public abstract class DbContextBase : DbContext, IContext, IDisposable { protected DbContextBase(string connection) : base(connection) { SetConfigurationProperties(); } protected DbContextBase(string connection, DbCompiledModel model) : base(connection, model) { SetConfigurationProperties(); } protected DbContextBase(System.Data.Common.DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection) { SetConfigurationProperties(); } protected DbContextBase(System.Data.Common.DbConnection existingConnection, System.Data.Entity.Infrastructure.DbCompiledModel model, bool contextOwnsConnection) : base(existingConnection, model, contextOwnsConnection) { SetConfigurationProperties(); } public void SetDbConnectionString(String name) { base.Database.Connection.ConnectionString = name; } private void SetConfigurationProperties() { this.Configuration.ProxyCreationEnabled = false; this.Configuration.LazyLoadingEnabled = false; } // etc.but I don't see where should we plug opening of the key into this code (and if it should be done here or not). Can you please provide a sample or provide me with a reference to a blog of how this should be done in EF?