ef 数据库连接字符串加密
public testContext() : base(GetConnection(), true) { } public static DbConnection GetConnection() { var providerName = ConfigurationManager.ConnectionStrings["testContext"].ProviderName; var conn = DbProviderFactories.GetFactory(providerName).CreateConnection(); var connectString = ConfigurationManager.ConnectionStrings["testContext"].ConnectionString; conn.ConnectionString = connectString.Decrypt();//解密 return conn; }