I am using Entity Framework to create a SQLServer connection of database with a password:
connectionString="DataSource=|DataDirectory|DB.sdf;Password=abc
How can I protect the password while using Entity Framework?
I am using Entity Framework to create a SQLServer connection of database with a password:
connectionString="DataSource=|DataDirectory|DB.sdf;Password=abc
How can I protect the password while using Entity Framework?
 
    
     
    
        ConnectionStringsSection oSection = Configuration.ServiceConfiguration.GetConnectionStrings();
    if(!oSection.SectionInformation.IsLocked && !oSection.SectionInformation.IsProtected)
    {
        oSection.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider"); 
        oSection.CurrentConfiguration.Save();
    }
 
    
    If you have access to the server, you can use the web config encryption tool from cmd. I create a .bat file in the same folder as my web.config containing:
aspnet_regiis -pef connectionStrings .
aspnet_regiis -pef appSettings .
pause
This will encrypt the connectionStrings whole section and in my case, the appSettings whole section too.
To Decrypt, do:
aspnet_regiis -pdf connectionStrings .
aspnet_regiis -pdf appSettings .
pause
You will need to run this from the server though.
 
    
    You can write EncDecHelper.Decrypt by using samples from here: Encrypt/Decrypt string in .NET
You will find the related information from here: Encrypt password in App.config
 
    
    